summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-18 10:38:47 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-18 10:38:47 -0800
commit555a2d0c47b34f933735f65ba6b0c21079234ba5 (patch)
tree1ea5ebf58569ba3eb2f0e5e673758428420ab3e4
parent42e124aa0ffad6696bbea8bd33b0e046fb48ce12 (diff)
downloadtxr-555a2d0c47b34f933735f65ba6b0c21079234ba5.tar.gz
txr-555a2d0c47b34f933735f65ba6b0c21079234ba5.tar.bz2
txr-555a2d0c47b34f933735f65ba6b0c21079234ba5.zip
int-flo: take advantage of unsigned range.
* arith.c (int_flo): If the floating point value is in the ucnum range, we can convert to integer by way of that type; we gain a little bit of range. For instance on 32 bits, floating values in the range 2147483648.0 to 4294967295.0 can be converted via the fast path.
-rw-r--r--arith.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arith.c b/arith.c
index 1420d65d..401e9693 100644
--- a/arith.c
+++ b/arith.c
@@ -2367,6 +2367,9 @@ val int_flo(val f)
if (n < NUM_MIN || n > NUM_MAX)
return bignum(n);
return num_fast(n);
+ } else if (d >= 0 && d <= UINT_PTR_MAX) {
+ ucnum n = d;
+ return unum(n);
} else {
char text[128];
char mint[128] = "", mfrac[128] = "", *pint = mint;