4 ms·
Except in floating point arithmetic there aren't two equidistant integers. What I expect is, Mathematica doesn't make promises about stuff that can be affected
by tagrun 10y ago
Except in floating point arithmetic there aren't two equidistant integers.
What I expect is, Mathematica doesn't make promises about stuff that can be affected by an infinitesimal change, with a floating point input. I don't think you can talk about "numbers of the form x.5" precisely with floating point. Mathematica typically behaves differently with inputs 1/2 and 0.5, so I'm not sure what's going here. I guess Round[] works slightly differently, maybe tries to fractionalize the input first.
I checked, and that promise is still there actually, under Details section.
- SamReidHughes 10y ago> Except in floating point arithmetic there aren't two equidistant integers. Yes there are. 1 and 2 are equidistant from 1.5. > I don't think you can talk about "numbers of the form x.5" precisely with floating point. Yes you can.
- tagrun 10y agoIf only IEEE-754 math worked as infinite-precision math. You should first learn some basics about floating point numbers before attempting to make such strong assertions to correct people with such a bossy attitude (you're 100% wrong BTW). Here's a quick exercise for you: #include <stdio.h> int main() { float x = 123456789.5; printf("%f\n", x); return 0; } prints 123456792.000000 And the distance between two nearest floats grow larger as you go away from 0. So the nearest existing integers aren't 123456790 or 123456788 either.
- SamReidHughes 10y agoMeanwhile, 2 - 1.5 == 1.5 - 1, and in half the integer range, the .5's can be represented exactly.
- tagrun 10y agoI think I've wasted enough time with your ignorant ramblings. Yeah, yeah, go and live with your delusions happily ever, "pal". Shoo.
- SamReidHughes 10y agoGuess what pal, even IEEE defines the round to even mode for results exactly between two integers (when they're the nearest representable values).