Useful Functions

version 1 by ShadowChaser

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 5 - Percentage

    percentage_suffix is some text that varies. The percentage_suffix is "%".
    percentage_precision is a number that varies. The percentage_precision is 2.

    To (dividend - a number) percentage of (divisor - a number):
        let quotient_integral be (dividend * 100) / divisor;
        say "[quotient_integral]";
        if percentage_precision > 0 begin;
            say ".[run paragraph on]";
            let quotient_remainder be remainder after dividing dividend by divisor;
            let pp be percentage_precision;
            while pp > 0 begin;
                let quotient_digit be quotient_remainder * 10 / divisor;
                say "[quotient_digit]";
                let quotient_remainder be remainder after dividing (quotient_remainder * 10) by divisor;
                let pp be pp - 1;
            end while;
        end if;
        say "[percentage_suffix]".
        
    To say (dividend - a number) percentage of (divisor - a number):
        dividend percentage of divisor.