Tip: Use Doubles for time ratios

BlitzMax Forums/BlitzMax Programming/Tip: Use Doubles for time ratios

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I've been fiddling with my Fixed Rate Logic code and realised that the floats I was using to return a delta value were totally imprecise for the job when the millisecs counter is quite high, so changed to doubles and now it works lush. Plus I also found a potential problem with the rounding of consts even if you typecast them as doubles!

see this:

Print "" 'blankline

time = MilliSecs()
Print "millisecs="+time

myfloat# = time/5.0
Print "float ="+myfloat

mydouble:Double = time/5.0
Print "double="+mydouble

Const MyConst = 43251254
Print "const =" + Double(MyConst/5.0)

Print "direct=" + Double(43251254/5.0)

MyInt = 43251254
Print "Int   =" + Double(MyInt/5.0)


- Code shows that float doesn't give precise enough value when dividing millisecs()
- Code shows that constants or direct constants passed into the equation round!
- Code shows that ints passed into the equation work as expected.

Wonder if this a bug with Constants?

This sort of ifo is very useful for delta timing and 3D apps and physics simulations etc.