This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: double precision problem


Philippe Després wrote:
> 
> Hello,
> 
> I am working on a nonlinear dynamics project and I recently pass from
> visual C++ on Windows to gcc on linux (x86). I need finite precision on
> double representation, and I can't have it with gcc . Example:
> 
> double x=cos(0.2); (16 digits)
> printf("%20.20f",x) on windows gives
> x=0.98006657784124163000;
>  while on linux, the last 3 digits are non-zero. How do I tell the
> compiler to force those 3 digits to be 0?? I have tried --ffloat-store
> option without positive results.

I think, at 17 digits, you reached the limit of the precision of the
double type with x86.

The long double type may be more helpful if you need more digits. Also,
careful considerations to arithmetic calculations need to be made.
-- 
Curtis R. Anderson, Co-creator of "Gleepy the Hen", SP 2.5?, KoX
Vacuum a cat today! (The rest of this space is reserved.)
http://www.madbbs.com/~gleepy/         ICQ: 50137888
mailto:gleepy@intelligencia.com        UTM: PS 7036 7315, zone 17


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]