Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How to avoid wrong answers in simple arithmetic expressions.
Replies: 13   Last Post: Jan 20, 2013 7:18 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
S.K.Mody

Posts: 31
Registered: 12/13/04
Re: How to avoid wrong answers in simple arithmetic expressions.
Posted: Jan 20, 2013 7:18 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <kdgm4e$f19$1@newscl01ah.mathworks.com>...
> "SK " <modysk@hotmail.com> wrote in message <kdgkg1$a14$1@newscl01ah.mathworks.com>...
> >
> > All right, suppose I say all integers between -2^52 and 2^52 can be represented exactly - I did say "within some range" without specifying what that range was.

>
> That's better.
>
> All integers are sum of powers of 2 (or powers of x, x is whatever you like), so there is no point in involving the basis when discussing integer in floating-poimt coding. The range 2^52 come from the fact that 52 bit is used by the mantissa of double precision IEEE.
>
> Very often miss-believing occur when user manipulate fractional number such as 0.1. The number 0.1 = 1/10 = 1/(2*5) cannot be represented exactly in binary basis, and human notation for 0.1 happens to be finite because we count in 10 basis. On the other hand 0.1 cannot be codded finitely in binary basis (computer), just like 1/3 cannot be written with finite decimal digit numbers. Therefore non-accuracy occurs in arithmetic operations for decimal fractional numbers.
>
> Bruno


Thank you for your help.

By the way the following is from the Wikipedia article on IEEE 754 - 1985
(http://en.wikipedia.org/wiki/IEEE_754-1985)
"In 1976 Intel began planning to produce a floating point coprocessor. Dr John Palmer, the manager of the effort, persuaded them that they should try to develop a standard for all their floating point operations. William Kahan was hired as a consultant; he had helped improve the accuracy of Hewlett Packard's calculators. Kahan initially recommended that the floating point base be decimal[8] but the hardware design of the coprocessor was too far advanced to make that change."

Perhaps it would have been more "human" for the floating point base to be in decimal. Not sure of any other consequences though.

Best Regards.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.