This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: gnu software bugs - long double


On 11/02/2013 11:19 PM, Jonathan Wakely wrote:
On 2 November 2013 22:12, Mischa Baars wrote:
On 11/02/2013 11:06 PM, Jonathan Wakely wrote:
On 2 November 2013 21:52, Mischa Baars wrote:
You are mistaken :)

Indeed some rational numbers can only be represented up to a certain
number
of bits, like 1 / 3. Others can be exactly represented, like 1 / 8.

All real numbers, and therefore all rational numbers, can be represented
up
to a certain number of bits.
i.e. not exactly.

Converting 1.1 from string to double should not be a problem.
That's not what your program does. It converts (long double)1.1, which
is not equal to 1.1, to a string.

I'm trying to pass a completely normal value to the debugger and to the
standard output, and do not convert any value to a string.
Seriously?  How do you think printf writes to standard output if not
converting to a string?

So that what glibc does :) That's not my doing.


And 1.1 is not representable as long double.

If you are willing to stop being so arrogant for a few minutes and
learn something try running this program and think about what the
result means:

#include <assert.h>

int main()
{
   long double l = 1.1;
   long double ll = 10 * l;
   assert( ll == 11 );
}

If you think GCC gets this result wrong then please use a different
compiler and stop wasting everyone's time, this is off-topic for this
mailing list.

There's no converting to any string in your example. You only convert source code strings into their corresponding doubles.

What I'm trying to point out is that the output differs from the value entered in the source. The string 1.1 from the source is not correctly converted to it's corresponding double, or the double is not correctly converted back into it's corresponding string.


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