Which holds for faster maths?

Blitz3D Forums/Blitz3D Programming/Which holds for faster maths?

D4NM4N(Posted 2006) [#1]
Which of the following is more efficient when compiled to M.Code?:

a=b/4

or

a=b*.25


for some reason i think the second one (from some very distant college assembly knowlage that is now gone) but just want to check (im writing some real number crunch stuff and every little helps :)


H&K(Posted 2006) [#2]
Well the second one definatly gives a float as an anwser.

A=b ror 2 (or maybe a=b shr 2), dont use b3d sorry


Mr Snidesmin(Posted 2006) [#3]
It's a matter of data types. If the data type of b is float then the second one would be faster because no conversion would be needed. If it's an integer then the first one would be faster.

I think both * and / result in the same operation in the processor.


GfK(Posted 2006) [#4]
Tested the original question in Blitzmax with 1 million iterations.

a=b/4 = 122ms
a=b*0.25 = 119ms

Conclusion: The difference is so miniscule, it isn't worth worrying about.


D4NM4N(Posted 2006) [#5]
all are float
ok, thanx jfk...

Now we know :)

why didnt i think of that, must be gettin old