We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3767

Summary: provide ldexp() as an alternative to scalbn()
Product: SDL Reporter: Ozkan Sezer <sezeroz>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   

Description Ozkan Sezer 2017-08-21 23:02:22 UTC
The following patch makes SDL_scalbn() to return ldexp(), which is C89,
if scalbn() is not present and FLT_RADIX == 2.

----

SDL_scalbn: return ldexp() if scalbn is not present and FLT_RADIX == 2

diff -r 23000b73ce4e src/stdlib/SDL_stdlib.c
--- a/src/stdlib/SDL_stdlib.c
+++ b/src/stdlib/SDL_stdlib.c
@@ -181,6 +187,10 @@ SDL_scalbn(double x, int n)
     return scalbn(x, n);
 #elif defined(HAVE__SCALB)
     return _scalb(x, n);
+#elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
+/* from scalbn(3): If FLT_RADIX equals 2 (which is
+ * usual), then scalbn() is equivalent to ldexp(3). */
+    return ldexp(x, n);
 #else
     return SDL_uclibc_scalbn(x, n);
 #endif /* HAVE_SCALBN */
Comment 1 Ryan C. Gordon 2017-08-29 04:42:35 UTC
This patch is now https://hg.libsdl.org/SDL/rev/bd5b569b2a1b, thanks!

--ryan.