   -0.0 floating point number?
  Is there any significance to math operations if one of the values is -0.0 (float)?  Somehow I end up with this in my vector normalization function (.x/length, .y/length)..  would this affect signs in calculations?It''s so odd.  Only me.  
  Shouldn't affect calcs. Two possible reasons for it, as far as I know. One, the bit that represents the sign of the number is set at negative even though all the mantissa bits are 0. Two, the output may be formatted to truncate some significant digits, e.g., number might be -0.000000000000132, but is formatted to the screen as %8.6f, which would come out as-0.00000I guess if its the latter case then the calcs will be affected if you really wanted the number to be exactly 0.Graham RhodesSenior ScientistApplied Research Associates, Inc.   [edited by - grhodes_at_work on February 4, 2004 5:41:26 PM];  Its most probably the second reason grhodes_at_work posted... I personally have never seen a floating point number come out as exactly -0. ;quote:Original post by SpaceDude  Its most probably the second reason grhodes_at_work posted... I personally have never seen a floating point number come out as exactly -0.   It''s not that uncommon. If, for instance, x=0.0 and length is negative, x/length would come out as -0.0.;  Is vector length supposed to always be positive (ie, unsigned)?  Or is that only with a unit vector?Maybe that signals a problem in my math....?;  A length should always be non-negative, yes. Maybe if you post the code we could tell if there is something wrong. ;  I read some time ago that -0 is actually necessary for certain computations.  In certain fluid flow simulations, a lack of -0 results in incorrect values.  The article was in IRC Dr. Dobbs a few years back.  The author discussed why he thought that DEC Alpha CPU made a mistake in its exception handling of floats.  It also mentioned that a C++ complex class is insufficient and that the then-pending C99 spec''s handling of complex numbers was a proper way to handle them.  I''m sorry, but I don''t remember much more about it.;quote:Original post by Anonymous Poster  It''s not that uncommon. If, for instance, x=0.0 and length is negative, x/length would come out as -0.0.It doesn''t, it comes at as 0.try running this:double x = 0;double length = -10;double test = x/length; ;  I did, and it comes out as -0.0.;  I have seen it return 0 or -0 on different machines, who knows why. But it shouldn''t effect anything. If you wanted to make sure you could make little function that would correct for zero.if(x < 0.00001f &&  x > -0.00001f )x=0.0f;I think it is just a waste. orYou could always just cast a float to an int and back. Never tried it but it seems reasonable. //should just truncate and retun a whole numberfloat shouldbezero(float x){return ((float) ((int)x));}  