Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » General Discussions » General Discussion » OT: Can someone explain this?
Re: OT: Can someone explain this? [message #183334 is a reply to message #183221] Fri, 23 December 2005 12:30 Go to previous messageGo to previous message
=HT=T-Bird is currently offline  =HT=T-Bird
Messages: 712
Registered: June 2005
Karma:
Colonel
Mathematics assumes that numbers have infinite precision. However, that's not possible with computers that use floating-point arithmetic, so you get round-off that gives you really tiny numbers instead of 0. Example of the WRONG way to do things (in C++):

float f1 = 2.0 - 1.0;
float f2 = 1.0;
if (f1 == f2)
std::cout << "this might not happen";
else
std::cout << "oops...floating point round-off";

(I still haven't figured out how to insert tabs in forum posts Sad )
and the RIGHT way:
float f1 = 2.0 - 1.0;
float f2 = 1.0;
if (std::fabs (f1 - f2) < std::numeric_limits <float>::epsilion ())
std::cout << "this works";


I hope this helps


HTT-Bird (IRC)
HTTBird (WOL)
Proud HazTeam Lieutenant.
BlackIntel Coder & Moderator.

If you have trouble running BIATCH on your FDS, have some questions about a BIATCH message or log entry, or think that BIATCH spit out a false positive, PLEASE contact the BlackIntel coding team and avoid wasting the time of others.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: What OS are YOU?
Next Topic: Freud would have a field day with this
Goto Forum:
  


Current Time: Sat Jul 19 09:00:03 MST 2025

Total time taken to generate the page: 0.04245 seconds