General This forum is for nontechnical general discussion which can include both Linux and nonLinux 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 LQrelated cookies.

Introduction to Linux  A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free. 


09082008, 04:14 PM

#1

Member
Registered: Apr 2006
Distribution: Fedora
Posts: 478
Rep:

FloatingPoint 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 floatingpoint arithmetic is not associative nor distributive, but I just don't understand how (especially the associative part). Could someone please explain this to me?



09082008, 05:20 PM

#2

Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,511
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 nonassociative or nondistributive.

Steve Stites



09082008, 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 nonassociative or nondistributive.

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.



09082008, 06:00 PM

#4

Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,511
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



09082008, 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.



09082008, 06:38 PM

#6

Senior Member
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,758
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 Trelated elements" will actually be larger than Q
When two 'floating point numbers' are being added, then such "maximal mutually Trelated elements" are being added.
Best
A. Mani



09092008, 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 floatingpoint 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 04:20 PM.

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

