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 - provide ldexp() as an alternative to scalbn()
Summary: provide ldexp() as an alternative to scalbn()
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-21 23:02 UTC by Ozkan Sezer
Modified: 2017-08-29 04:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.