mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
AK: Implement floating-point conversions for big-endian
This commit is contained in:
parent
c99674c6ac
commit
1bc44376c0
Notes:
sideshowbarker
2024-07-17 09:56:35 +09:00
Author: https://github.com/sideeffect42
Commit: 1bc44376c0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/415
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/DanShaders
3 changed files with 83 additions and 36 deletions
22
AK/Math.h
22
AK/Math.h
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/FloatingPoint.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StdLibExtraDetails.h>
|
||||
|
@ -765,14 +766,21 @@ constexpr T log2(T x)
|
|||
|
||||
// FIXME: Handle denormalized numbers separately
|
||||
|
||||
FloatExtractor<T> mantissa_ext {
|
||||
.mantissa = ext.mantissa,
|
||||
.exponent = FloatExtractor<T>::exponent_bias,
|
||||
.sign = ext.sign
|
||||
};
|
||||
|
||||
// (1 <= mantissa < 2)
|
||||
T m = mantissa_ext.d;
|
||||
T m;
|
||||
if constexpr (HostIsLittleEndian) {
|
||||
m = ((FloatExtractor<T>) {
|
||||
.mantissa = ext.mantissa,
|
||||
.exponent = FloatExtractor<T>::exponent_bias,
|
||||
.sign = ext.sign })
|
||||
.d;
|
||||
} else {
|
||||
m = ((FloatExtractor<T>) {
|
||||
.sign = ext.sign,
|
||||
.exponent = FloatExtractor<T>::exponent_bias,
|
||||
.mantissa = ext.mantissa })
|
||||
.d;
|
||||
}
|
||||
|
||||
// This is a reconstruction of one of Sun's algorithms
|
||||
// They use a transformation to lower the problem space,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue