09-17-2005, 09:27 PM
Quote:The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as resultI assume it's the same for QB - but that's pretty vague on what rounding to integer means... does it round floating-point values to an integer that is still stored in a floating-point representation, or does it round to integer and convert to an integer type? I would assume it is the latter (convert to integer type) because of the fact that 2,147,483,647 is the highest possible value - this is also the largest positive value a signed 4-byte integer (LONG) can hold.
Quote:I set up a test with the number DIMed as DOUBLE. When the input number was equal to 2,147,483,647 an overflow error was issued.I also did a test and an overflow only occurred with the value 2,147,483,648, not 2,147,483,647.
Code:
DIM a AS DOUBLE, b AS DOUBLE, c AS DOUBLE
a = 2147483647#
b = 2147483647#
c = a MOD b
PRINT c