aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/numX.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-24 19:04:37 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-24 19:06:23 -0500
commitcb336b312e7012dc05fe7d8ac1c0e924dbc6c840 (patch)
treed2b8242e46452d12bfb1f7812f6965e64ddf9dfa /src/stdlib/numX.h
parent649977aae7e5922f992cd69eb84da0a2db368580 (diff)
Shuffle dependencies around so header files aren't needed after tomo has
been compiled
Diffstat (limited to 'src/stdlib/numX.h')
-rw-r--r--src/stdlib/numX.h33
1 files changed, 2 insertions, 31 deletions
diff --git a/src/stdlib/numX.h b/src/stdlib/numX.h
index 3d65cb59..210c4cc7 100644
--- a/src/stdlib/numX.h
+++ b/src/stdlib/numX.h
@@ -9,7 +9,6 @@
#include <stdint.h>
#include "datatypes.h"
-#include "stdlib.h"
#include "types.h"
#include "util.h"
@@ -58,36 +57,8 @@ MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_num32)(float n) { return (NUM_T)n; }
MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_num64)(double n) { return (NUM_T)n; }
#endif
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-#endif
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int)(Int_t i, bool truncate) {
- if likely (i.small & 0x1) {
- NUM_T ret = (NUM_T)(i.small >> 2);
- if unlikely (!truncate && (int64_t)ret != (i.small >> 2))
- fail("Could not convert integer to " TYPE_STR " without losing precision: ", i.small >> 2);
- return ret;
- } else {
- NUM_T ret = mpz_get_d(i.big);
- if (!truncate) {
- mpz_t roundtrip;
- mpz_init_set_d(roundtrip, (double)ret);
- if unlikely (mpz_cmp(i.big, roundtrip) != 0)
- fail("Could not convert integer to " TYPE_STR " without losing precision: ", i);
- }
- return ret;
- }
-}
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int64)(Int64_t i, bool truncate) {
- NUM_T n = (NUM_T)i;
- if unlikely (!truncate && (Int64_t)n != i)
- fail("Could not convert integer to " TYPE_STR " without losing precision: ", i);
- return n;
-}
+CONSTFUNC NUM_T NAMESPACED(from_int)(Int_t i, bool truncate);
+CONSTFUNC NUM_T NAMESPACED(from_int64)(Int64_t i, bool truncate);
MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int32)(Int32_t i) { return (NUM_T)i; }
MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int16)(Int16_t i) { return (NUM_T)i; }
MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int8)(Int8_t i) { return (NUM_T)i; }