Are there positive ints a,b s.t. floor((double)a/b)!=a/b ? (C expressions, 32-bit int)
-
Show this thread
-
Replying to @RichFelker
Assuming 32b int and IEEE double, surely not, because only one rounding.
2 replies 0 retweets 0 likes -
-
Replying to @RichFelker @stephentyrone
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/
1 reply 0 retweets 2 likes -
Replying to @volatile_void @stephentyrone
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.
1 reply 0 retweets 0 likes -
BTW is that still true if a,b can range up to 53 bit? Looks borderline but probably still safe.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @volatile_void
Yes, as long as a and b convert exactly you’re fine.
1 reply 0 retweets 0 likes -
Replying to @stephentyrone @volatile_void
(2^54 - 2)/(2^54 - 1) is >1 ulp away from 1.0 so that looks ok.
2 replies 0 retweets 0 likes -
Replying to @RichFelker @volatile_void
2^54 - 1 isn't representable as a double; are you sure you don't mean 2^53 - 1?
1 reply 0 retweets 0 likes -
The >1ulp bound is clear converting the division to geometric series, treating denominator as 1-x.
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.