Square function?
-
What is the square function in VC++? I have tried using : pow(a, 2); but its ridiculously slow (i need to perform many such calculations), now i`ve just got (a*a) instead (which is crap loads quicker). I just need to know that I`ve gone about it the right way. Cheers all, Alan.:-D AEGC
-
What is the square function in VC++? I have tried using : pow(a, 2); but its ridiculously slow (i need to perform many such calculations), now i`ve just got (a*a) instead (which is crap loads quicker). I just need to know that I`ve gone about it the right way. Cheers all, Alan.:-D AEGC
The fastest way to calculate the square of a number would be to use the * operator as you have already tried out. When you do a*a that's about the best you can do. Because it translates into the MUL instructions directly. But if you want to do floating point squaring then I am not sure. Perhaps you could try using logarithms [which involve addtitions and not multiplications] which might speed up things. In the DOS days I remember how we used to set the compiler/linker options to generate 80x87 code that speeded up the mathematics. I wonder whether there is some such thing for win32 stuff too. Regards Nish Sonork ID 100.9786 voidmain
-
The fastest way to calculate the square of a number would be to use the * operator as you have already tried out. When you do a*a that's about the best you can do. Because it translates into the MUL instructions directly. But if you want to do floating point squaring then I am not sure. Perhaps you could try using logarithms [which involve addtitions and not multiplications] which might speed up things. In the DOS days I remember how we used to set the compiler/linker options to generate 80x87 code that speeded up the mathematics. I wonder whether there is some such thing for win32 stuff too. Regards Nish Sonork ID 100.9786 voidmain