| General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-08-2008, 04:14 PM
|
#1
|
|
Member
Registered: Apr 2006
Distribution: Fedora
Posts: 478
Rep:
|
Floating-Point Arithmetic Not Associative or Distributive?
Hello,
I'm taking a course in Computer Architecture, and one of the topics is on binary representations of numbers in the computer. One of the points that they make is that floating-point arithmetic is not associative nor distributive, but I just don't understand how (especially the associative part). Could someone please explain this to me?
|
|
|
|
09-08-2008, 05:20 PM
|
#2
|
|
Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Squeeze, Fedora 14
Posts: 7,268
Rep:
|
Actually floating point arithmetic is associative and distributive.
Floating point numbers have a fixed length which means that round off errors are common. You have to give some consideration to the order of your calculations and the magnitude of your intermediate results to minimize the effect of round off errors. If you do a sequence of calculations in several different orders you can get several different final results depending on how fast the round off errors propagate through the various intermediate results. All of this is a consequence of round off errors and does not mean that floating point arithmetic is non-associative or non-distributive.
-----------------------
Steve Stites
|
|
|
|
09-08-2008, 05:46 PM
|
#3
|
|
Senior Member
Registered: Sep 2003
Posts: 3,171
Rep: 
|
Quote:
|
All of this is a consequence of round off errors and does not mean that floating point arithmetic is non-associative or non-distributive.
|
Actually, that is exactly what it means. Associative means that A*(B*C) = (A*B)*C, but given roundoff errors and number magnitudes etc this can be easily shown to not be true in all cases with computer floating point arithmetic. Hence, computer fp arithmetic is not associative.
Similarly, distributive property says that (A+B)*C = A*C + B*C. Again, it is simple to show that this is not true using computer fp arithmetic.
The fact is that the breakdown of these rules is due to a defect in the floating point arithmetic scheme, where word size turns out to be very important. But the existence of the defect leads to the consequence.
|
|
|
|
09-08-2008, 06:00 PM
|
#4
|
|
Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Squeeze, Fedora 14
Posts: 7,268
Rep:
|
jiml8
Semantically what you say is correct but it is misleading. Suppose a student programmer solves a complex calculation using two different valid arithmetic sequences and gets two different answers. When he asks what is wrong are you going to tell him that floating point arithmetic does not follow the rules of algebra or are you going to explain the effects of roundoff errors and number magnitudes on intermediate results?
---------------------
Steve Stites
|
|
|
|
09-08-2008, 06:11 PM
|
#5
|
|
Senior Member
Registered: Sep 2003
Posts: 3,171
Rep: 
|
I am going to tell him that because of the limitations of the hardware, the numerical approximations to the mathematical functions are not associative or distributive, and therefore he has to pay attention to the order of his operations.
|
|
|
|
09-08-2008, 06:38 PM
|
#6
|
|
Senior Member
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,726
Rep: 
|
From the practical point of view, the main thing is to keep track of the progression of errors.
In computer sci, you use the rationals and not the reals usually.
Formally floating point arithmetic is actually being done over a "set that is larger than the set of rationals".
Q - field of rationals
Define a reflexive and symmetric relation T on Q via
$(x,y)\,\in\,T$ iff <your limitation on bounds based condition>
Now the set of "maximal mutually T-related elements" will actually be larger than Q
When two 'floating point numbers' are being added, then such "maximal mutually T-related elements" are being added.
Best
A. Mani
|
|
|
|
09-09-2008, 06:24 PM
|
#7
|
|
Member
Registered: Apr 2006
Distribution: Fedora
Posts: 478
Original Poster
Rep:
|
Thanks jiml8, that's kind of what I thought, but I was (and still am a little) confused over the exact reason. What confuses me even more is that if you take floating-point arithmetic in the real world (outside of the confines of a digital circuit), then normal mathematical concepts apply. aaarrrggghhh!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:35 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|