hi
i am running a program in C++ that calls (amongst other things) the exp function several hundred times. When i use doubles the program runs approx 10% faster than with floats. Can anyone explain why this might be?
cheers
richard
Printable View
hi
i am running a program in C++ that calls (amongst other things) the exp function several hundred times. When i use doubles the program runs approx 10% faster than with floats. Can anyone explain why this might be?
cheers
richard
Which one from a lot of exp types are you using?
//edit: ... and how did you measure and for what build?
hi
i am using c++ under Gcc. As i understand it, in this system the compiler automatically selects the appropiate exp for example expf for a float. One cannot specify which type of exp to use.
http://www.cplusplus.com/reference/clibrary/cmath/exp/
Well, I don't know how Gcc implements this function but assuming your link:I'd guess that Gcc may use casting/converting operations for floats to double and back to use only this variant:Quote:
Portability
In C, only the double version of this function exists with this name.
BTW, you haven't answer how you measured... :rolleyes:Code:double exp ( double x );