[Gambas-user] Math bugs??
Grahame White
grahame at ...457...
Fri Jun 11 18:13:18 CEST 2004
On Friday 11 June 2004 16:34, Brant Wells wrote:
> Hey All.
>
> My name is Brant Wells, and I'm from the USA. I hope this finds
> everyone well...
>
> I have found a bug, I do believe... If you do something like:
>
> dim myVar as float
>
> myvar=1/2
>
> Then myvar comes out to be zero, when it should come out to be 0.5... I
<quote>
The Gambas divide / operator returns an integer if its operands are all
integers. For example, PRINT 9 / 2 returns 4 and not 4.5 . To use floating
point division, you must convert one of the operands to the Float
datatype, e.g. you must use PRINT 9.0 / 2 or PRINT CFloat(9) / 2 . In VB,
division using / is always a floating-point operation, with an implicit
conversion to doubles prior to the division and if necessary, an implicit
conversion back to integer afterward; VB has a separate integer division
operator.
</quote>
That's from the gambas help files in the Differences from VB section. So
it's not a bug, it's a feature :)
Grahame
More information about the User
mailing list