Hi Jon!

Thanks for your reply.

On Sat, Jul 20, 2013 at 12:17 PM, JonY <jo...@users.sourceforge.net> wrote:
> On 7/20/2013 23:43, K. Frank wrote:
>> Hello List!
>>
>> On 64-bit mingw-w64:
>>
>>    g++ (rubenvb-4.8-stdthread) 4.8.1 20130324 (prerelease)
>>
>> on 64-bit windows 7, I'm seeing that long doubles have a precision of about
>> 18 decimal digits.  I would guess that this is a legacy of the old 8087 
>> 80-bit
>> internal floating-point number.
>>
>>>From a quick test program (no explicit compiler flags):
>> ...
>>    numeric_limits<long double>::digits10 = 18
>> ...
>>    numeric_limits<long double>::max_digits10 = 21
>> ...
>>    sizeof(long double) = 16
>>
>> As you can see, long double offers only a modest increase in precision over
>> double, but takes fully twice the space.
>>
>> Also, Intel's old 80-bit floating-point format fits in five 16-bit
>> words (which fits in
>> three 32-bit words).  I am guessing that alignment issues on a 64-bit machine
>> make it not worth the bother to use less than a full two 64-bit words to 
>> hold a
>> long double, even though (if I'm right about the 80-bit
>> representation), there's a
>> fair amount of wasted space.
>>
>> Does this all sound right?
>
> on a 64-bit machine, floating point goes on SSE registers, which support
> 2x64-bit floats (128-bit per xmm reg). On a 32-bit machine, it goes on
> the 80-bit x87 fpu.

That would certainly make sense, but it doesn't square with what
numeric_limits is telling me:

   numeric_limits<long double>::digits10 = 18
   numeric_limits<long double>::max_digits10 = 21

Just to check that numeric_limits isn't lying to me I ran a small program
that adds and subtracts 1.0 to and from a small long double.  This agrees
with numeric_limits and shows about 20 decimal digits of precision.

   ---------------
   d = 1e-017
   (d += 1.0;  d -= 1.0;)
   d = 9.97466e-018
   ---------------
   d = 1e-018
   (d += 1.0;  d -= 1.0;)
   d = 9.75782e-019
   ---------------
   d = 1e-019
   (d += 1.0;  d -= 1.0;)
   d = 1.0842e-019
   ---------------
   d = 1e-020
   (d += 1.0;  d -= 1.0;)
   d = 0
   ---------------

I compiled the test program without any special compiler flags.  Do I
need to somehow enable the SSE registers you mentioned in order
to take advantage of them?

> Use something like MPFR if you want arbitrary high precision math
> independent of hardware capabilities.

No, I don't need that.  I was just a little curious about what I saw, and
thought an 80-bit long double was a little skimpy for a modern, 64-bit
machine.


Thanks for any additional wisdom.


K. Frank

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to