[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Long double arithmetics

From: Roman Fleysher
Subject: Long double arithmetics
Date: Sat, 29 Nov 2003 22:52:44 -0500


I have been trying to use long double to improve accuracy of my code and
ran into the following problem. When I execute the test code:

 long double    x,y;

 while(x != x+y)
   y /= 2.0L;

 printf("%Le \n",y);

I get 5.421011e-20, which corresponds to 2^-64. If I remove "long" in the
variable declaration to make it double, the result does not change. The
size of long double is 12 bytes and that of double is 8. Where did the
extra bytes go, I thought I will get some for mantissa? Or perhaps +-/*
operations are defined on double and not long double? (To make sure the
variable type has effect, I changed it to float and the result was
5.960464e-08, which is about what I would expect.) I would appreciate your
clarifications on this problem.

Thank you for your help,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]