[Gambas-user] Possible error when doing math on bytes
Benoit Minisini
benoit.minisini at gambas-basic.org
Tue Jan 3 23:40:09 CET 2023
Le 03/01/2023 à 23:08, Brian G a écrit :
> When I do math on bytes I get an overflow now when the value of the
> byte goes negative
> example:
> dim a as byte = 0
> dim b as byte = 24
> dim result as byte = a - b
>
> This causes an overflow error, where in the past it was just a negative
> number.
> Is this a bug or a new undocumented feature?
>
Overflows were ignored before, as it is usually the case in C programs,
even if the behaviour of overflows is unspecified. It's for speed
reasons, or to make hacking easier, I dunno.
So I decided to detect them, for a small performance penalty.
The overflow checks are only disabled on 'Fast Unsafe' functions.
Regards,
--
Benoît Minisini.
More information about the User
mailing list