|
-
June 30th, 2010, 04:00 AM
#1
exp with floats and doubles
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
-
June 30th, 2010, 05:10 AM
#2
Re: exp with floats and doubles
Which one from a lot of exp types are you using?
//edit: ... and how did you measure and for what build?
Victor Nijegorodov
-
June 30th, 2010, 07:04 AM
#3
Re: exp with floats and doubles
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/
-
June 30th, 2010, 07:12 AM
#4
Re: exp with floats and doubles
 Originally Posted by riched158
Well, I don't know how Gcc implements this function but assuming your link:
Portability
In C, only the double version of this function exists with this name.
I'd guess that Gcc may use casting/converting operations for floats to double and back to use only this variant:
Code:
double exp ( double x );
BTW, you haven't answer how you measured...
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|