Having written almost no code I hit a consistancy issue that has me confused. I've seen a few people post similar sorts of questions so I figure that one of those ASM decompiler people might be able to tell me what happening.
Below are two programs, they are almost identical. The first one does some simple math with longs, then floats, the second one does the same thing with longs then the second part with doubles.
Not supprisingly, longs are faster than floats which are faster than doubles but why are longs faster when paired with doubles than they are with floats? Shouldn't they be about the same? It's always a 10% difference
Output is:
(FLOATS)
Starting...
Integer Iterations: 543523
Floating Point Iterations: 419996
(DOUBLES)
Starting...
Integer Iterations: 629507
Floating Point Iterations: 92694

Is it just me? There are only three character changes in the code samples .f changed to .d in three places and nothing in the scope of the longs where the difference is being seen
Code is (Doubles):
Code: Select all
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
OpenConsole()
Timer.d = ElapsedMilliseconds()
IntIterations = 0
PrintN("Starting...")
Delay(20)
While ElapsedMilliseconds() < Timer + TimeToRun
IntA.l = 1234
IntB.l = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns.l = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Timer.d = ElapsedMilliseconds()
FpIterations = 0
Delay(100) ;let the cpus calm down
While ElapsedMilliseconds() < Timer + TimeToRun
FPA.d = 1234.1234
FPB.d = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.d = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Input()
CloseConsole()
Code: Select all
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
OpenConsole()
Timer.d = ElapsedMilliseconds()
IntIterations = 0
PrintN("Starting...")
Delay(20)
While ElapsedMilliseconds() < Timer + TimeToRun
IntA.l = 1234
IntB.l = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns.l = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Timer.d = ElapsedMilliseconds()
FpIterations = 0
Delay(100) ;let the cpus calm down
While ElapsedMilliseconds() < Timer + TimeToRun
FPA.f = 1234.1234
FPB.f = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.f = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Input()
CloseConsole()