Author: Robert Hyatt
Date: 20:06:36 09/09/02
Go up one level in this thread
On September 09, 2002 at 12:05:27, Vincent Diepeveen wrote: >On September 09, 2002 at 10:04:12, Ed Panek wrote: > >Which compiler did you use? > >It is exactly these reasons that i was very sick from >intel c++ compiler, because it is doing everything >wrong with casts of floating point math. >you write 'java oddity' above. intel j++ exists nowadays? It isn't a compiler problem it is an IEEE floating point problem in that .1 can not be comverted exactly, it becomes an approximation. 2.01 == 2.009997 roughly. * 1000 = 2009.997, truncated to a long gives 2009. No bug. No error. Floating point conversion followed by integer conversion makes this natural. > >>long x; >>double y; >> >>y = 2.01; >>x = (long)(y * 1000); >> >> >>guess what x equals? ... >> >>No, not 2010, but 2009 !!!!!!!!!!!!!!! >> >>Ed
This page took 0.01 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.