Assume current rounding mode is not known.
Are there positive ints a,b s.t. floor((double)a/b)!=a/b ? (C expressions, 32-bit int)
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Assuming 32b int and IEEE double, surely not, because only one rounding.
-
There are 2 roundings: inexact / and floor.
-
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?
- 2 more replies
New conversation -
-
-
Surely not: IEEE doubles represent 32-bit ints exactly, and the divide should be exact or have error ~= 2^-20 no matter rounding mode.
-
Does the magnitude of the rounding error matter? Even a tiny error can cross an integer boundary.
-
I suppose, but I don't think there's any results which will actually do so? (2^32-1)/(2^32-1) has a fractional component large enough that it swamps any errors, and that seems like it's at or near the worst case.
End of conversation
New conversation -
-
-
z3 can probably solve this for you :D. I'd try it myself, but right now eating dinner :(.
-
https://rise4fun.com/Z3/8opld but I might have encoded this wrongly
-
Still much better than I could've done, considering the circumstances (EEATINGDINNER). Tyvm :D!
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.