mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibM: Specialiase FloatExtractor for long double as well
This commit is contained in:
parent
a13f2b7df3
commit
190952675e
Notes:
sideshowbarker
2024-07-18 21:36:06 +09:00
Author: https://github.com/RealKC Commit: https://github.com/SerenityOS/serenity/commit/190952675e1 Pull-request: https://github.com/SerenityOS/serenity/pull/5688 Issue: https://github.com/SerenityOS/serenity/issues/4282 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/awesomekling
1 changed files with 20 additions and 0 deletions
|
@ -24,6 +24,8 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibC/assert.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
@ -67,6 +69,24 @@ enum class RoundingMode {
|
|||
template<typename T>
|
||||
union FloatExtractor;
|
||||
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
// This assumes long double is 80 bits, which is true with GCC on Intel platforms
|
||||
template<>
|
||||
union FloatExtractor<long double> {
|
||||
static const int mantissa_bits = 64;
|
||||
static const unsigned long long mantissa_max = ~0u;
|
||||
static const int exponent_bias = 16383;
|
||||
static const int exponent_bits = 15;
|
||||
static const unsigned exponent_max = 32767;
|
||||
struct {
|
||||
unsigned long long mantissa;
|
||||
unsigned exponent : 15;
|
||||
unsigned sign : 1;
|
||||
};
|
||||
long double d;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
union FloatExtractor<double> {
|
||||
static const int mantissa_bits = 52;
|
||||
|
|
Loading…
Add table
Reference in a new issue