move f32 to h.h, add reinterpreting helper methods
This commit is contained in:
parent
9bb7fa406b
commit
c3347d6815
@ -41,9 +41,6 @@ B sub_c1(B t, B x);
|
||||
B fne_c1(B t, B x);
|
||||
B shape_c2(B t, B w, B x);
|
||||
|
||||
// TODO move to h.h
|
||||
typedef float f32;
|
||||
|
||||
// all divint/floordiv/modint assume integer arguments
|
||||
// floordiv will return float result only on ¯2147483648÷¯1 or n÷0, but may not otherwise squeeze integer types; integer argument requirement may be relaxed in the future
|
||||
// divint will return float result if there's a fractional result, or in overflow cases same as floordiv
|
||||
|
||||
11
src/h.h
11
src/h.h
@ -113,6 +113,7 @@ typedef uint32_t u32;
|
||||
typedef int64_t i64;
|
||||
typedef uint64_t u64;
|
||||
typedef double f64;
|
||||
typedef float f32;
|
||||
typedef size_t ux;
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
#define HAS_U128 1
|
||||
@ -232,6 +233,16 @@ typedef union B {
|
||||
} B;
|
||||
#define b(x) ((B)(x))
|
||||
|
||||
typedef union { u32 u; f32 f; } F32R;
|
||||
FORCE_INLINE u64 r_f64u(f64 x) { return ((B) x).u; }
|
||||
FORCE_INLINE f64 r_u64f(u64 x) { return ((B) x).f; }
|
||||
FORCE_INLINE u32 r_f32u(f32 x) { return ((F32R) x).u; }
|
||||
FORCE_INLINE f32 r_u32f(u32 x) { return ((F32R) x).f; }
|
||||
FORCE_INLINE u64 r_Bu(B x) { return x.u; }
|
||||
FORCE_INLINE f64 r_Bf(B x) { return x.f; }
|
||||
FORCE_INLINE B r_uB(u64 x) { return b(x); }
|
||||
FORCE_INLINE B r_fB(f64 x) { return b(x); }
|
||||
|
||||
#if defined(RT_WRAP) || defined(WRAP_NNBI)
|
||||
#define IF_WRAP(X) X
|
||||
#else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user