Churky, you have complete missed my point about IEEE-754. By no means
is it"a way to tell people that I can get a whole number from an
arithmetic" -- whatever that was really supposed to mean.

IEEE-754 is a standard for floating point computations. It describes
the required accuracy for a wide variety of floating point operations,
including the five rounding modes I mentioned.

Before you make irresponsible claims comparing this to the Challenger
exploding, you need to learn the basics of floating point
representation and accuracy. You have not shown awareness of this yet.
Especially since it took you three tries to get the numbers right.

But assuming you finally did really get them right, once again, Python
also implements IEEE-754, and yields:

>>>102.0 * .0254
2.5907999999999998

(>>> is the Python prompt. The next line is the output). THis is the
same as the figure you quote.

Now the fact that it is off by the 4th decimal place is completely
irrelevant: the accuracy is still 2 parts in a gazillion, well within
spec. To be precise, it is an error of only 4.4408920985006262e-16,
ridiculously small.

If you still do not agree, then you really, REALLY need to review
Knuth's "The Art of Computer Programming" Vol II, in the section on
floating point representation and arithmetic (chapter 4). For this is
really, really basic stuff. There is no bug here.

On Sep 4, 6:45 am, Churky <[email protected]> wrote:
> So according to Koysta, The IEEE-754, is a way to tell people that I
> can get a whole number from an arithmetic, but Instead I am going to
> get a trailing slightly off value? So that means IEEE-754 is the
> answer to the US space shuttle Challenger exploding? And it is ok and
> acceptable? And I am talking about just 5 decimal places and it
> already off. i am surprise that no one else here post anything about
> this. From a quick search before I posted.
>
> I'm not a rocket scientist, but the point is, multiplying always
> yields a non trailing number unlike division. So why is it ok to have
> 2 numbers multiple together and allow it to have a slightly off the
> exact value?
>
> On Sep 4, 2:43 am, Indicator Veritatis <[email protected]> wrote:
>
> > As Kostya already commented, this is rounding error. The error is well
> > within the acceptable range for IEEE-754 floating point
> > multiplication, since the inaccuracy is still only 2 parts in 10^13.
>
> > Still, it is a little embarrassing, considering that Python also
> > implements IEEE-754, and gets it exactly right: 100.0 * 0.0254 yields
> > 2.54. I wonder which rounding modes (there are 5 different choices in
> > IEEE-754) Python and Android (resp.) chose to implement.
>
> > In fact, a few casual Google searches, such as "floating point
> > rounding Android", yield nothing about what choices they made when
> > implementing IEEE-754. It doesn't even yield who is responsible for
> > this: the OEM or the authors of Android itself.
>
> > BTW: I didn't check too thoroughly, but it looks to me like despite
> > appearances, 0.254 is not exactly representable in binary -- it has
> > lots of trailing zeros followed by yet more digits.
>
> > On Sep 3, 2:59 pm, Churky <[email protected]> wrote:
>
> > > When Performing a division or multiplication. The value does not equal
> > > to the arithmetic.
> > > example i have:
>
> > > double value = 100 * .0254;
>
> > > in real life equals = 2.5908
>
> > > While android calculates it to: 2.5907999999999998 which is wrong.
>
> > > I have verified this in the emulator using multiple machines, and
> > > multiple version of android.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to