NO

Author Topic: value of LDBL_EPSILON  (Read 2345 times)

Offline agoodeno

  • Member
  • *
  • Posts: 2
value of LDBL_EPSILON
« on: July 10, 2019, 04:22:48 AM »
In float.h, the value of LDBL_EPSILON is given as equal to the DBL_EPSILON, just to more decimal places. I believe the correct value of LDBL_EPSILON (on IEEE 754 platforms) should be 1.084202172485504434007452e-19L.

My workaround is to add in my own .h file:
#undef LDBL_EPSILON
#define LBDL_EPSILON 1.084202172485504434007452e-19L

Hope to see this easy fix in the next version of Pelles C!

Alan

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2098
Re: value of LDBL_EPSILON
« Reply #1 on: July 10, 2019, 10:49:48 AM »
Pelles C double and long double are same size, 64-bit.
Same thing with msvc.

https://en.wikipedia.org/wiki/Machine_epsilon

https://stackoverflow.com/questions/3478743/trying-to-write-a-code-for-finding-the-machine-epsilon/37379119#37379119
Code: [Select]
FLT_EPSILON:  1.19209e-07
DBL_EPSILON:  2.22045e-16
LDBL_EPSILON: 1.0842e-19
May the source be with you

Offline agoodeno

  • Member
  • *
  • Posts: 2
Re: value of LDBL_EPSILON
« Reply #2 on: July 10, 2019, 02:41:55 PM »
Interesting.

Why would MSVC not support long double? It's in the C and IEE-754 standards and the FPU supports it. I suppose Pelles didn't support it either just to remain "compatible" with MSVC.

An algorithm that calculates the minimum or maximum of a mathematical function can theoretically be determined only to within the square root of the machine epsilon, so a minimum/maximum function needs all the precision it can get!

Alan

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2098
Re: value of LDBL_EPSILON
« Reply #3 on: July 10, 2019, 07:00:12 PM »
Why would MSVC not support long double?
They did before Visual C++ and 32-bit.
Some others still supported that 'extended' like gcc, Delphi, ... (FPU 80 bit).

Quite stupid idea from C standard group folks, that allows long double to be double, who really needs that alias ?
Why not just use defines or typedefs, when retard system don't support long double, to support some ancient program codes ?
May the source be with you

Offline agoodeno

  • Member
  • *
  • Posts: 2
Re: value of LDBL_EPSILON
« Reply #4 on: July 10, 2019, 10:39:49 PM »
Thanks Timo for your explanation. I guess there just isn't any need to write programs using long doubles in Pelles C or MSVC, since they don't do anything more than doubles do. This bug report can be closed.

Alan