[Gambas-user] Bug with * operator (I think)
Benoît Minisini
gambas at ...1...
Wed Mar 31 22:46:07 CEST 2010
> Hi!
> I'm using Gambas 3 rev 2822 @ Ubuntu 9.10 64bit.
>
> To IDE console;
>
> ?3413156131^2
> 1.164963477458E+19
> Right.
>
> ?3413156131*3413156131
> -6797109299126662455
> Wrong.
>
>
> Or in code;
>
> dim y as long = 3413156131
> Print (y * (1 + y)) / 2
>
> Result;
> -3398554647856753152
> Wrong.
The '*' operator (like '+' and '-') returns the same datatype as its
arguments. There is no conversion to a bigger datatype if needed, so the
result is truncated.
>
>
> Also, is there possibility to define integer variable bigger than 64bit?
No.
> I need really big numbers...
Find a volunteer to implement a Gambas component based on a library that can
manage big integers, like that one: http://gmplib.org/
Regards,
--
Benoît Minisini
More information about the User
mailing list