comp.lang.ada
 help / color / mirror / Atom feed
From: dvdeug@x8b4e516e.dhcp.okstate.edu (David Starner)
Subject: Re: Why no new posts ?
Date: 2000/11/15
Date: 2000-11-15T00:00:00+00:00	[thread overview]
Message-ID: <8ut9n3$8a21@news.cis.okstate.edu> (raw)
In-Reply-To: 002001c04ec8$27db8ee0$b0375140@Fudge

On Tue, 14 Nov 2000 21:51:51 -0800, JF Harrison wrote:
>This is a multi-part message in MIME format.

Please don't send MIME to the newsgroup, especially not program binaries.

>Want some posts?
>How about some beginner level questions from my end.
>
>One in this post and another following.
>
>First off:
>I got a Very strange error in dividing real numbers.  I divided 12345670.0
>by 100.0 and got 123456.70313 as the answer!  I have certainly able to have
>flawless divisions but also isolated some code that will repeatably
>demonstrate this.  I still dont know what is wrong with the code; perhaps
>you can tell me.

First, for almost any question like this, we need to know which platform
you're on and which compiler you're using. (Windows on ix86, I assume?)

This may sound insulting, but do you know that real numbers are stored in
binary? Division by powers of ten is not going to come out exactly right.
Float also does not have very much precision. From what I'm looking at,
float on the ix86 has 6 decimal digits of precision, which doesn't 
correspond to your numbers, because your numbers are _too_ correct. Still,
you're using a low precision float type in base 2, which means division by
100.0 is not going to be exact, and you'll easily get visibly wrong 
answers.

-- 
David Starner - dstarner98@aasaa.ofe.org
http://dvdeug.dhis.org
As centuries of pulp novels and late-night Christian broadcasting have taught 
us, anything we don't understand can be used for the purposes of Evil.
	-- Kenneth Hite, Suppressed Transmissions




  parent reply	other threads:[~2000-11-15  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-14  0:00 Why no new posts ? William J. Thomas
2000-11-14  0:00 ` Vincent Marciante
2000-11-15  7:33   ` Chris Miller
     [not found] ` <002001c04ec8$27db8ee0$b0375140@Fudge>
2000-11-15  0:00   ` David Starner [this message]
2000-11-15  0:00   ` Why no new posts ? Float accuracy Nicolas Brunot
2000-11-15  0:00     ` Jean-Pierre Rosen
2000-11-15  0:00   ` Why no new posts ? Martin Dowie
     [not found] ` <002a01c04eca$dbaecc00$b0375140@Fudge>
2000-11-15  7:24   ` tmoran
2000-11-15  7:38   ` tmoran
2000-11-16  2:44   ` DuckE
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox