"Webdiyer" <we******@hotmail.com> wrote in message
news:OJ*************@TK2MSFTNGP11.phx.gbl...
Hi,
We all know that the return value of Math.Log(8,2) is 3,
No it's not. Math.Log(8,2) is a double precision floating point value
guaranteed only to be pretty darn close to 3.
It's like the add for the new Delta shaver:
It's not just close, it's Eplsilon-close!
In particular (3 - double.Epsilon) < Math.Log(8,2) < (3 + double.Epsilon).
When you convert it to an integral type, you should explicitly apply
whatever rounding behavior you want. Or else perform your arithmetic on
integers only.
David