Skip to content
Prev 65543 / 398506 Next

a==0 vs as.integer(a)==0 vs all.equal(a,0)

Robin Hankin <r.hankin at soc.soton.ac.uk> writes:
Not if you want things to work in the large-integer domain...

You're in somewhat murky waters here because it all has to do with
whether you can rely on the floating point aritmetic being exact for
integers up to 2^53. *If* that works, then there's really no reason to
distrust "==" in this context and the gcd() works as originally
written. You might consider wrapping it in a function that checks
whether a and b are both (1) in range and (2) that they are integers
in the sense that round(x)==x. (Failing 2, you likely get an infinite
recursion).