I'm sure this isn't the first time this has been mentioned, but I'm curious about floats vs integers and whether large integers would be better for 3D programming than single or double precision floats. I'm working on a project for DOS, and of course I'm trying to get as much speed as possible out of the compiler. Using this code...
Code: Select all
Dim i As Integer
Dim p As Integer
Dim q as Single
Dim r as Double
Dim t As Double
t = Timer
For i = 0 To 5000000
p *= 2
Next
Print Timer - t
t = Timer
For i = 0 To 5000000
q *= 2
Next
Print Timer - t
t = Timer
For i = 0 To 5000000
r *= 2
Next
Print Timer - t
Code: Select all
0.01235959999030456
0.01628820001496933
0.01628129999153316
...and these results in DOSBox-X using 486 with FPU enabled @ 30000 cycles.
Code: Select all
0.6599998474121094
0.9900000093367432
0.9900000093367432
Almost a 50% cost. Seems like using big integers instead of floats might have a much bigger saving in that environment than I'd been lead to believe. I'm going to try it on a real piece of hardware with a x87 FPU if I can find such a thing, but just thought the results were interesting.