perlquestion
soulchild
Today I stumbled across the following piece
of code and I'm still wondering why the condition is not
met:
<code>
my $a = 36.8;
my $b = 36.6;
if( $a >= ( $b + 0.2 ) ) { print "true\n"; }
</code>
=> returns nothing (Why's that? 36.8 equals 36.6 + 0.2)
<br><br>
Whereas the condition becomes true if I change the values
a little bit:
<code>
my $a = 6.8;
my $b = 6.6;
if( $a >= ( $b + 0.2 ) ) { print "true\n"; }
</code>
=> returns "true" (that's what i expected)
<br><br>
I feel a little bit stupid asking this question and have
the strange feeling that my mind is playing a trick on me
here because I've been doing perl stuff since many years now. Must have got something to do with floating point
values and the "greater or equal than" operator, I guess.
<br><br>
Could somebody please tell me why the above code fragments
work like they do and not how I think they should work?
<br><br>
Thanx!