This is related to issue 1555, but the types at play are different, so the underlying problem might be different too.
rem
seems to be returning very incorrect results between bigint and float. Note the large difference in using 10000
as the divisor vs 1e4
:
user> (rem 9037601485536036300227801N 10000)
7801N
user> (long (rem 9037601485536036300227801N 1e4))
1073741824
test.check
provides a tighter example of clearly incorrect results:
user> (rem 9007199254740993N 2)
1N
user> (rem 9007199254740993N 2.0)
0.0
Here's a generative test to reproduce this result:
(clojure.test.check/quick-check
100 (prop/for-all [l gen/size-bounded-bigint
r (gen/fmap inc gen/nat)]
(== (rem l (double r))
(rem l (long r)))))