Log2 seems inefficient

KENNON J CONRAD via Cygwin <[email protected]>
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
Hello,
 
   I am not an experienced cygwin user but have been using it to compile code on Windows (gcc), so I may be leaving out some key details.  My issue is that for every log2 call in my code there is a divide that follows a log library call in the assembly code.  It appears to be related to these lines in math.h:
 
#if !defined(__cplusplus)
#define log2(x) (log (x) / _M_LN2)
#endif
 
My questions are:  If log(x) is used, wouldn't it be faster to multiply by constant (1/LN2) instead of divide by constant (LN2)?  And wouldn't it be even more efficient to compute log2 directly instead of computing the natural log and then converting it to log2?
 
I realize this is not a "bug", it just doesn't seem very optimal from an speed standpoint.
 
Best Regards,
 
Kennon Conrad
 
 

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.