[Gambas-user] Elusive Gambas3 crashing bug
Benoît Minisini
gambas at ...1...
Tue Nov 16 02:51:14 CET 2010
> > More...
> >
> > Dim TestSingle As Single
> > Dim pp As Pointer
> >
> > TestSingle = 33.1
> > pp = VarPtr(TestSingle)
> >
> > SinglePtr(pp) = 33.1 is False! Gives -2...
> >
> > Jussi
>
> Actually SinglePtr() cannot work on local variables, because internally
> there is no "Single" local variable, only "Float".
>
> Thanks for detecting that weird thing!
Full Single management has been implemented in revision #3296.
Note that floating point constants (33.1 for example) are always Float. So if
you compare SinglePtr(pp) to 33.1, the Single value returned by SinglePtr() is
converted to a Float before doing the comparison, and so the values do not
match.
To force a Single comparison, do: SinglePtr(pp) = CSng(33.1)
Regards,
--
Benoît Minisini
More information about the User
mailing list