tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: joe () resptk ! bhp ! com ! au (Joe Spanicek)
To: tru64-unix-managers
Subject: SUMM: BUG in 'modf' function ????
Date: Mon, 07 Apr 1997 01:13:07 +0000	[thread overview]
Message-ID: <96078611110240.tru64-unix-managers.marc@archive.invalid> (raw)

Hi all,

I got a quick reply that sums up the problem:

The promotion of a 'float' to 'double' is causing
the problem, so I opted to use the 'modff' function for
floats.

Thanks

PS: there is NO bug in 'modf'



> Hi Joe
> 
> > Could someone confirm whether the following is a BUG
> > with the 'modf' function or me doing something wrong !!!
> > ...
> > Or does this have to do with promoting 'value1' from a float to
> > a double ???
> > In any case the 'modf' function looks like it returns '1.0' or is this
> > really '0.99999999999999999' and the printf's '%f' prints this as a 1.0 ??
> 
> It's really 0.9999997169 which you can see if you change your output
> format from %f to %15.10g.
> 
> Inserting this line after the calculation of x1 x2:
> 
>    printf ("%s %g   %s %g\n", "x1-21:", x1-21,"x2-21:", x2-21);
> 
> gives:
> 
>    x1-21: -2.83122e-07   x2-21: 0
> 
> This shows the source of your problem.  The value of x1 is less than
> 21 because of the lower precision of float compared with double.
> 
> Cheers
> Ian
> 
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> _/                                                           Ian Mortimer _/
> _/ Email: mortimer@physics.uq.edu.au  ,-_|\         Department of Physics _/
> _/ Tel  : +61 7 3365 3436            /    *\     University of Queensland _/
> _/ Fax  : +61 7 3365 1242            \_,-._/          St. Lucia, Brisbane _/
> _/                                        v    Queensland, Australia 4072 _/
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> Disclaimer: Any opinions expressed are my own.
> 
> 

                 reply	other threads:[~1997-04-07  1:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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