J
JoeU2004
Would someone who has Excel 2007 running on an Intel-compatible computer
(i.e. not a Mac) please try the examples below and post your results here?
I posted this inquiry to an Excel 2010 blog. Not sure if/when I'll hear
back from them.
(Extra credit: If you have Excel 2010 running on an Intel-compatible
computer, feel to try these examples and post your results here, too.)
Has the following Excel 2003 problem been fixed in 2010 (or 2007)?
INT(123456789 - 0.0000004) returns 123456789 instead of 123456788.
This causes a problem in formulas like the following: if A1 is
=123456789-0.0000004, =A1-INT(A1) is negative unexpectedly, about -4.917E-07
when formatted as General.
In contrast, INT(123456789 - 0.0000005) returns 123456788 as expected, and
myInt(123456789 - 0.0000004) returns 123456788, where myInt() is the
following UDF:
Function myInt(x as Double) as Double
myInt = Int(x)
End Function
Note that 123456789 - 0.0000004 is represented internally as about
123456788.999999,598, whereas 123456789 - 0.0000005 is about
123456788.999999,493 internally. (The comma demarcates the first 15
significant digits.)
So I suspect that the Excel INT algorithm is effectively, albeit perhaps
unintentionally, rounding its argument to 15 significant digits before
truncating to an integer. It shouldn't.
Indeed, the largest expression involving 123456789 that returns an incorrect
INT value is 123456789 - 33*2^-26, which is represented internally as about
123456788.999999,508, whereas 123456789 - 34*2^-26 is about
123456789.999999,493 internally.
As you might imagine, the problem is not limited to 123456789 - 0.0000004.
And the problem will not appear with some combinations that you might think
are similar, e.g. 100000000 - 0.0000004.
You need to look at the exact conversion of the internal binary
representation -- that is, beyond the first 15 significant digits -- to
determine whether or not to expect a problem. Most people cannot; I can.
(i.e. not a Mac) please try the examples below and post your results here?
I posted this inquiry to an Excel 2010 blog. Not sure if/when I'll hear
back from them.
(Extra credit: If you have Excel 2010 running on an Intel-compatible
computer, feel to try these examples and post your results here, too.)
Has the following Excel 2003 problem been fixed in 2010 (or 2007)?
INT(123456789 - 0.0000004) returns 123456789 instead of 123456788.
This causes a problem in formulas like the following: if A1 is
=123456789-0.0000004, =A1-INT(A1) is negative unexpectedly, about -4.917E-07
when formatted as General.
In contrast, INT(123456789 - 0.0000005) returns 123456788 as expected, and
myInt(123456789 - 0.0000004) returns 123456788, where myInt() is the
following UDF:
Function myInt(x as Double) as Double
myInt = Int(x)
End Function
Note that 123456789 - 0.0000004 is represented internally as about
123456788.999999,598, whereas 123456789 - 0.0000005 is about
123456788.999999,493 internally. (The comma demarcates the first 15
significant digits.)
So I suspect that the Excel INT algorithm is effectively, albeit perhaps
unintentionally, rounding its argument to 15 significant digits before
truncating to an integer. It shouldn't.
Indeed, the largest expression involving 123456789 that returns an incorrect
INT value is 123456789 - 33*2^-26, which is represented internally as about
123456788.999999,508, whereas 123456789 - 34*2^-26 is about
123456789.999999,493 internally.
As you might imagine, the problem is not limited to 123456789 - 0.0000004.
And the problem will not appear with some combinations that you might think
are similar, e.g. 100000000 - 0.0000004.
You need to look at the exact conversion of the internal binary
representation -- that is, beyond the first 15 significant digits -- to
determine whether or not to expect a problem. Most people cannot; I can.