Re: Comparison issue

2012-03-20 Thread Ali Çehreli
On 03/20/2012 02:08 AM, Don Clugston wrote: > For starters, note that ANY integer expression which is exact, is also > exact in floating point. With the note that the integer type has better precision at higher values. For example, there are many 32-bit values that uint can, but float cannot r

Re: Comparison issue

2012-03-20 Thread Don Clugston
On 19/03/12 15:45, H. S. Teoh wrote: On Mon, Mar 19, 2012 at 08:50:02AM -0400, bearophile wrote: James Miller: writeln(v1 == 1); //false writeln(v1 == 1.0); //false writeln(v1 == 1.0f); //false writeln(v1+1 == 2.0f); //true Maybe I'd like to deprecate a

Re: Comparison issue

2012-03-19 Thread H. S. Teoh
On Mon, Mar 19, 2012 at 08:50:02AM -0400, bearophile wrote: > James Miller: > > > writeln(v1 == 1); //false > > writeln(v1 == 1.0); //false > > writeln(v1 == 1.0f); //false > > writeln(v1+1 == 2.0f); //true Using == to compare floating point values is wrong. Due to

Re: Comparison issue

2012-03-19 Thread Jesse Phillips
On Monday, 19 March 2012 at 12:50:02 UTC, bearophile wrote: James Miller: writeln(v1 == 1); //false writeln(v1 == 1.0); //false writeln(v1 == 1.0f); //false writeln(v1+1 == 2.0f); //true Maybe I'd like to deprecate and then statically forbid the use of == amon

Re: Comparison issue

2012-03-19 Thread James Miller
On Mar 20, 2012 1:50 AM, "bearophile" wrote: > > James Miller: > > > writeln(v1 == 1); //false > > writeln(v1 == 1.0); //false > > writeln(v1 == 1.0f); //false > > writeln(v1+1 == 2.0f); //true > > Maybe I'd like to deprecate and then statically forbid the use of ==

Re: Comparison issue

2012-03-19 Thread bearophile
James Miller: > writeln(v1 == 1); //false > writeln(v1 == 1.0); //false > writeln(v1 == 1.0f); //false > writeln(v1+1 == 2.0f); //true Maybe I'd like to deprecate and then statically forbid the use of == among floating point values, and replace it with a library-d

Comparison issue

2012-03-19 Thread James Miller
Hey, I'm trying to do some vector based code, and my unittests started to fail on testing normalize. I'm using the standard algorithm, but the assert is always return false. I did some investigation, and can show that this program causes failure: import std.math : sqrt; import std.stdio :