More debugger checks (variable ranges)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

More debugger checks (variable ranges)

Post 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)
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post 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
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yep, I will take a look !
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post 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!
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

Please optional!
Maybe its good, to keep it optional.
Because of the reason GPI mentioned, maybe also because of speed reasons... :?:
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply