Are there positive ints a,b s.t. floor((double)a/b)!=a/b ? (C expressions, 32-bit int)
-
-
The rounding taking place in (double)a/b cannot take the result on the other side of (integer truncated) a/b, though, because (integer truncated) a/b is representable as a double and would be a better result candidate than whatever candidate below it for the result of the double/
-
The interesting question wasn't whether it crosses a/b but whether it crosses a/b+1. But I guess it can't do that either.
-
BTW is that still true if a,b can range up to 53 bit? Looks borderline but probably still safe.
-
Yes, as long as a and b convert exactly you’re fine.
-
(2^54 - 2)/(2^54 - 1) is >1 ulp away from 1.0 so that looks ok.
-
2^54 - 1 isn't representable as a double; are you sure you don't mean 2^53 - 1?
-
Indeed, 2^53 - 1.
-
The >1ulp bound is clear converting the division to geometric series, treating denominator as 1-x.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.