|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	| 
		
			| Re: OT: Can someone explain this? [message #183334 is a reply to message #183221] | Fri, 23 December 2005 12:30   |  
			| 
				
				
					|  =HT=T-Bird Messages: 712
 Registered: June 2005
 
	Karma: 0
 | 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
  ) 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.
 |  
	|  |  | 
	|  | 
	| 
		
			| Re: OT: Can someone explain this? [message #183349 is a reply to message #183339] | Fri, 23 December 2005 12:57   |  
			| 
				
				
					|  =HT=T-Bird Messages: 712
 Registered: June 2005
 
	Karma: 0
 | Colonel |  |  |  
	| | icedog90 wrote on Fri, 23 December 2005 13:45 |  | Why don't you use "using namespace std;" so that you don't have to put std:: in front of everything from the iostream library?
 
 | 
 It's bad form.  Dragging in namespaces wholesale leads to name conflicts m8...p.s. it's the STL, not the iostream library
 
 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.
 |  
	|  |  | 
	|  | 
	|  | 
	|  |