implement rint / rintf via lrint (#36)

* implement rint / rintf via lrint

* optimize

* prefer 32-bit regs for reinterpret cast

* clean unnecessary parentesis

* fixed
extensions
Max Graey 5 years ago committed by Volodymyr Shymanskyy
parent c77ccf65dc
commit a767630e45

@ -168,10 +168,27 @@ typedef short i16;
typedef uint8_t u8;
typedef int8_t i8;
static inline float rintf( float arg ) {
union { float f; uint32_t i; } u;
u.f = arg;
uint32_t ux = u.i & 0x7FFFFFFF;
if (UNLIKELY(ux == 0 || ux > 0x5A000000)) {
return arg;
}
return (float)lrint(arg);
}
static inline double rint( double arg ) {
union { double f; uint32_t i[2]; } u;
u.f = arg;
uint32_t ux = u.i[1] & 0x7FFFFFFF;
if (UNLIKELY((ux == 0 && u.i[0] == 0) || ux > 0x433FFFFF)) {
return arg;
}
return (double)lrint(arg);
}
//TODO
static inline float rintf( float arg ) { return .0f; }
static inline double rint ( double arg ) { return .0; }
static inline uint64_t strtoull ( const char* str, char ** endptr, int base ) { return 0; }
static inline uint64_t strtoull( const char* str, char ** endptr, int base ) { return 0; }
#endif

Loading…
Cancel
Save