Help with math errors

Blitz3D Forums/Blitz3D Programming/Help with math errors

Ghoula(Posted 2007) [#1]
Large numbers are calculated incorrectly sometimes, does anyone know of a way to get around this? Run the code below to see what i mean...

Graphics3D 1280,1024,32,1

SetBuffer BackBuffer()
Cls
HidePointer
Color 255,0,0

For t=1 To 100
    i=(t/100.0)*(10*10000000)
    Text 0,y,i
    y=y+15
Next

Flip

While Not KeyDown(1)
Wend


I'm trying to use these large calculations for the players income in my game. Thanks.


_33(Posted 2007) [#2]
Graphics3D 1280,1024,32,1

SetBuffer BackBuffer()
Cls
HidePointer
Color 255,0,0

For t=1 To 100
    i= t * 1000000
    Text 0,y,i
    y=y+15
Next

Flip

While Not KeyDown(1)
Wend


Works fine like this. Remember you're not dealing with doubles. You can see how much fits in a 32 bit signed int, or a 32 bit float. if you want to use floats, your number here is too big. Blitz3D requires a module to handle doubles, if you want 64 bit floats, and that would solve your problem permanently.

In other words, Blitz3D can't calculate B. Gates's budget.


Ghoula(Posted 2007) [#3]
Is there a module for Blitz3D that supports 64bit numbers? If so where, i've googled and have came up with nothing.

I know VB.NET has support for them, and BlitzMAX also i believe...sure would be alot of help in Blitz3D.

Here's what the real line of code for 'i=' looks like trying to determine income based on efficiency and economic level:
Income=Int((ModifiedEfficiency#/100)*(c\EconomicLevel*StandardIncomePerEconomicLevel))



Ghoula(Posted 2007) [#4]
I think i found something in the code archives for handling doubles, gonna play with them...Thanks for the help.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1971