« Return to Thread: gb3: incorrect solution to If...Then condition

Re: gb3: incorrect solution to If...Then condition

by Benoît Minisini :: Rate this Message:

| View in Thread

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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
Gambas-user@...
https://lists.sourceforge.net/lists/listinfo/gambas-user

 « Return to Thread: gb3: incorrect solution to If...Then condition