Notice that
-1,1102230246252E-16
is 
-0.00000000000000011102230246252
which can be viewed as 'zero' in certain circumstances.
If I may suggest..
Use an INT to control your zoom levels
then work the trig from that.
The INT for zoom would be your primary data.
Using floats can be very messy over many calculations.
-Nando


---------- Original Message -----------
From: Jussi Lahtinen <jussi.lahti...@gmail.com>
To: mailing list for gambas users <gambas-user@lists.sourceforge.net>
Sent: Fri, 27 Apr 2012 21:44:08 +0300
Subject: Re: [Gambas-user] gb3: incorrect solution to If...Then condition

> If Sin(0.5) ^ 2 + Cos(0.5) ^ 2 <> 1 Then
> Print "This shouldn't be seen, but it is."
> Endif
> 
> ? format((Sin(0.5) ^ 2 + Cos(0.5) ^ 2),"#.########################")
> 1
> 
> What is going on?
> 
> Jussi
> 
> 2012/4/27 Benoît Minisini <gam...@users.sourceforge.net>
> 
> > 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@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------------------------
> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------


------------------------------------------------------------------------------
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to