SCOUG-Programming Mailing List Archives
Return to [ 14 |
February |
2005 ]
<< Previous Message <<
>> Next Message >>
Content Type: text/plain
On Mon, 14 Feb 2005, Lynn Maxson wrote:
> Peter,
>
> "You gotta be kidding. They teach fractional arithmetic in
> junior high. And those kids still do it by hand. And they get
> the right answer (if they pass the course)."
>
> Fractional arithmetic that produces a real number? To how
> many places? If you come up with a result that is expressed
> as a fraction with a numerator and denominator, you don't
> have a real number. Period. You can take 2/3 of 6 (4), but
> you can't take 2/3 of 7 (4.??????...). You can't do it in
> fractional arithmetic except as 14/3. Neither you, a junior high
> school student, any computer, or software can under your
> terms of infinite precision. You can't do infinity. Maybe you're
> not clear on the concept.
This exchange makes one thing clear to me: The extra atributes
DECIMAL(23) and BINARY(12) are semantic sugar that is much more
poisonous than "... the incomplete world of "int" and "float"."
For those joining the discussion in middle, Peter and I are
talking about the EXACT same thing. You only have to look at
the root that makes up the terms "RATIOnal Number" and "RATIOnal
Arithmetic". Peter has given implementaiton details and I have
pointed out why "dcl f float decimal(256);" does NOT work as a
suitable approximation for rational numbers.
Rational arithmetic can be carried out exactly with NO loss of
precision as long as no overflow occurs. So you can take 2/3 of
6 and get the EXACT answer 4. You can also take 2/3 of 7 and
get the EXACT answer 14/3. You can also express this EXACTLY in
apprpriate positional numbering systems with the proper base.
In Base-3 numbering, the exact representation of the rational
number is 11.2; in Base-9, the representaiton is 4.6. You can
have an exact representation of THIS rational number in a
Base-N positional numbering system for Base-3, Base-6, Base-9,
Base-12, etc. You cannot have an exact representation in
Base-2 (binary) or Base-10 (decimal) positional numbering
systems. In decimal you get 4.666666666666666... where the
last digit repeats indefinitely.
I pointed out that rational arithmetic can be done exactly.
However, I should have also pointed out that once you have
cast your number as decimal or binary, then you have thrown
away that exactness. You can add 5/7 and 2/3 to get the
EXACT answer 29/21. You can multiply these two numbers and
get an EXACT answer of 10/21. You can also do this arithmetic
EXACTLY with a positional numbering system only as long as you
have the correct base for the number system. In a Base-21
number system we have rational(5/7) (where 5 and 7 are Base-10
integers) is 0.F in Base-21 and rational(2/3) is 0.E in Base-21.
This gives
0.F 0.F
+ 0.E and * 0.E
----- -----
1.8 0.A
Tough luck trying to get that right with what some people have
mistakenly characterized as "real" numbers in this discussion.
--
Gregory W. Smith (WD9GAY) gsmith@well.com
=====================================================
To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".
For problems, contact the list owner at
"postmaster@scoug.com".
=====================================================
<< Previous Message <<
>> Next Message >>
Return to [ 14 |
February |
2005 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|