mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[liba] Use softfloat IEEE754 getters implementation instead of
re-implementing them
This commit is contained in:
committed by
EmilieNumworks
parent
c0a9ec1c91
commit
ecb7ec403a
@@ -1,37 +1,22 @@
|
||||
#include <private/ieee754.h>
|
||||
#include "external/softfloat/include/internals.h"
|
||||
|
||||
uint32_t ieee754man32(float x) {
|
||||
union {
|
||||
float f;
|
||||
uint32_t i;
|
||||
} u;
|
||||
u.f = x;
|
||||
return (u.i & ((1<<23)-1));
|
||||
uint32_t * address = (uint32_t *)&x;
|
||||
return fracF32UI( *address );
|
||||
}
|
||||
|
||||
uint8_t ieee754exp32(float x) {
|
||||
union {
|
||||
float f;
|
||||
uint32_t i;
|
||||
} u;
|
||||
u.f = x;
|
||||
return (u.i >> 23) & 0xFF;
|
||||
uint32_t * address = (uint32_t *)&x;
|
||||
return expF32UI( *address );
|
||||
}
|
||||
|
||||
uint64_t ieee754man64(double x) {
|
||||
union {
|
||||
double d;
|
||||
uint64_t i;
|
||||
} u;
|
||||
u.d = x;
|
||||
return (u.i & (((uint64_t)1<<52)-1));
|
||||
uint64_t * address = (uint64_t *)&x;
|
||||
return fracF64UI( *address );
|
||||
}
|
||||
|
||||
uint16_t ieee754exp64(double x) {
|
||||
union {
|
||||
double d;
|
||||
uint64_t i;
|
||||
} u;
|
||||
u.d = x;
|
||||
return (uint16_t)((u.i >> 52) & 0x7FF);
|
||||
uint64_t * address = (uint64_t *)&x;
|
||||
return expF64UI( *address );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user