Fixed Point Maths

version 5 by Michael Callaghan

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 7 - Multiplication

    Section 1 - Multiplication of two fixed point numbers

    To decide which real number is (A - a real number) real times (B - a real number):
        let temp be the absolute value of A;
        let temp1_int be the whole part of temp;
        let temp1_dec be the fractional part of temp;
        let temp be the absolute value of B;
        let temp2_int be the whole part of temp;
        let temp2_dec be the fractional part of temp;
        let result_int be temp1_int times temp2_int;
        let temp1 be temp1_int times temp2_dec;
        let result_int be result_int plus the greater part of temp1;
        let result_dec be the lesser part of temp1;
        let temp1 be temp1_dec times temp2_int;
        let result_int be result_int plus the greater part of temp1;
        let result_dec be result_dec plus the lesser part of temp1;
        let temp1 be temp1_dec times temp2_dec;
        let result_dec be result_dec plus the greater part of temp1;
        if the lesser part of temp1 is greater than HalfDivisor:
            let result_dec be result_dec plus 1;
        let result_int be result_int plus the greater part of result_dec;
        let result_dec be the lesser part of result_dec;
        let result be the real number with whole part result_int fractional part result_dec;
        if A is negative:
            let result be the reverse of result;
            if B is negative:
                let result be the reverse of result;
        otherwise:
            if B is negative:
                let result be the reverse of result;
        decide on result.