TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTIAN FELDE
from: PETER HAYWOOD
date: 1997-11-30 00:55:00
subject: Re: What`s wrong?

Groovy hepcat Christian Felde jived with All on 03 Nov 97  16:52:00!
What's wrong?'s a cool scene. Dig it!
 CF> I have made this program that'll read the letter A, and the numbers 21
 CF> and 3.142 from the keyboard. 
 CF> It all seem to work well, and it compils just fine (no errors), but
 CF> when I type in 3.142, I get the error that I didn't type that: 
  As I'm sure other people will tell you, a float cannot always be
tested acurately. There's no guarantee that 3.142 can even be
represented acurately as a float, so how could a float object with a
value close to 3.142 be compared exactly to 3.142?
  It might help if you use a double or long double instead of a float,
but even that has no guarantee of success.
  Solution: instead of comparing your pi variable to 3.142 exactly,
compare it to 3.142ñ0.0005 or something. So instead of this:
if(pi == 3.142)
you could do this:
if((pi > 3.1415) && (pi < 3.1425))
                                                  Wolvaen
... It gets better every time, unless you do it with the same woman. - Al
--- Blue Wave/RA v2.20
---------------
* Origin: The Gate, Melbourne Australia, +61-3-9809-5097 33.6k (3:633/159)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.