Page 1 of 1

More debugger checks (variable ranges)

Posted: Sat May 03, 2003 6:01 pm
by Andre
Sent to me by another german user:

Code: Select all

DefType.l  a,b,c
a = -1073741824
b = 3
c = a * b
d$ = Str(c)
OpenConsole()
PrintN(d$)
dummy$ = Input()
CloseConsole()
; Result of PureBasic: 1073741824
; Correct result: -3221225472

The debugger should check a variable overflow and inform the user. Would avoid many false calculations... 8)

Posted: Sat May 03, 2003 6:06 pm
by Andre
Another example, which shows when float variables break their limits:

Code: Select all

 DefType.f   a,b,c
 a = -9999999999
 b = 108765.388
 c = a * b
 d$ = StrF(c)
 OpenConsole()
 PrintN(d$)
 dummy$ = Input()
 CloseConsole()
Result of PureBasic: -153366319595520
Correct result: -1087653879891234.612

Posted: Sat May 03, 2003 7:06 pm
by Fred
Yep, I will take a look !

Posted: Sat May 03, 2003 10:41 pm
by GPI
Please optional!

It can be usefull, for example with bytes. Because now:

a.b=255

is possible, but when a overflow-check is insert, not!

Posted: Sun May 04, 2003 1:16 pm
by Andre
Please optional!
Maybe its good, to keep it optional.
Because of the reason GPI mentioned, maybe also because of speed reasons... :?: