[fpc-pascal] Freepascal Floating Point Issue

Daniel Franzini daniel.franzini at gmail.com
Tue Aug 22 00:34:30 CEST 2017


It might be the case (I didn't do the math) that 999.999 doesn't have an
exact representation in IEEE-754 double-precision format, so the best you
get is an aproximation (a pretty good one, btw).

On Mon, Aug 21, 2017 at 7:10 PM, Ralf Quint <freedos.la at gmail.com> wrote:

> On 8/21/2017 3:02 PM, James Richters wrote:
> > I am having an issue with a simple floating point application.  I am
> setting a variable to a specific value and immediately after I set it,  it
> is not exactly what I set it to.  Here's an example
> >
> >    Draw_GX_Min:=999.999;
> >    Writeln(Draw_GX_Min:3:30);
> >
> > The writeln results in 999.999000000000020000000000000000
> >
> > Why is it not  999.999000000000000000000000000000  where did
> 0.00000000000002 come from?
> >
> Out of thin air... Well, kind of. Double floating point means 16 digits
> of precision, so when you force a 30 digit precision output, anything
> past 16 digits is random garbage, at best...
>
> Ralf
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>



-- 
Daniel

"Let us change our traditional attitude to the construction of programs.
Instead of imagining that our main task is to instruct a computer what to
do, let us concentrate rather on explaining to human beings what we want a
computer to do." (Donald Knuth)

"Yes, technogeeks can be funny, even if only to each other." (
http://www.boogieonline.com/revolution/science/humor/)"

"Man is driven to create; I know I really love to create things. And while
I'm not good at painting, drawing, or music, I can write software."
(Yukihiro Matsumoto, a.k.a. ``Matz'')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170821/cfff1dc9/attachment.html>


More information about the fpc-pascal mailing list