[Gambas-user] gb3: incorrect solution to If...Then condition
Benoît Minisini
gambas at ...1...
Fri Apr 27 05:17:20 CEST 2012
Le 27/04/2012 05:08, Kevin Fishburne a écrit :
> I'm using the latest build and have this code:
>
> If Zoom.Adjustment * 0.5>= Zoom.Maximum Then
> Zoom.Adjustment = Zoom.Adjustment * 0.5
> Endif
>
> Zoom.Adjustment and Zoom.Maximum are both singles. Zoom.Adjustment is 1
> and Zoom.Maximum is 0.5. The expression with these values returns False,
> which is blowing my mind. The same, untouched code worked fine before my
> recompile this evening. Any insight into WTF is going on here?
>
?CSingle(1) * 0.5 - CSingle(0.5)
-1,1102230246252E-16
0.5 is a Float, so CSingle(1) * 0.5 is a Float before doing the comparison.
You must write CSingle(0.5) to get a Single "0.5", and not a Float "0.5".
AFAIK 0.5 should be the same as a Float or as a Single (1*2^-1) (a
Gambas bug?), but anyway you must use CSingle for the other cases.
Regards,
--
Benoît Minisini
More information about the User
mailing list