TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Chris Mcbrien
from: Bob Liles
date: 1994-10-11 22:34:00
subject: C/set++

CM>        float temp=26.4;

CM>My system tells me the value is 2.639996E+01.  Now that's not a huge
CM>difference, I admit, but it's enough to really screw up my program.

Let me explain the reason for this.  The number 26.4 is a base 10 number
and can be expressed exactly in this base.  However, the computer is a
base 2 entity.  Base 2 numbers can be expressed exactly, but base 10
numbers must be approximated.  As you may be aware, base 2 numbers go up
in powers of 2.  They go 0, 1, 2, 4, 8, 16, etc.  As you may not be
aware, the base 2 fractions are also powers of 2.  They go 1, 1/2, 1/4,
1/8, 1/16, etc.  The number 26 can be expressed exactly in base 2 as
16 + 8 + 2.  However, the 0.4 part must be approximated.  The 0.4 is
equal to 4/10 or 2/5, neither of which is a base 2 number.  The closest
you will come is with 1/4 + 1/8 + 1/64 etc.  You will never find a
combination of base 2 fractions that will exactly equal 2/5.
___
 * MR/2 2.0 #99 * Internet: XTJX59A{at}PRODIGY.COM   RIME: ->7   Prodigy: XTJX59A

--- QScan v1.12b / 01-0169

* Origin: The Party Line * Memphis * 901-755-4531 (1:123/5)
SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413
SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1
@PATH: 123/5 4 301 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.