Fixed Point Maths

version 5 by Michael Callaghan

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 3 - Basic functions to convert numbers

    Section 1 - Int function converts to the nearest integer

    To decide which number is (N - a real number) as an integer:
        let result be the whole part of N;
        let temp1 be the absolute value of N;
        let temp2 be the fractional part of temp1;
        if temp2 is greater than HalfDivisor:
            if result is greater than 0:
                let result be result plus 1;
            if result is 0:
                let result be result plus 1;
            if result is less than 0:
                let result be result minus 1;
        decide on result.