Re: Error in returned value of sizeof(long double) in amd64?

2024-07-22 Thread pms-...@outlook.com

Michael Cheponis wrote:

a satellite
orbital prediction over very long times)


Is it public project such as Orbitron?
There are few of us here[*BSD world) doing similar stuff :) [as hobby]



Re: Error in returned value of sizeof(long double) in amd64?

2024-07-07 Thread Martin Husemann
On Sat, Jul 06, 2024 at 12:01:10PM -0700, Michael Cheponis wrote:
> Thank you.
> 
> We, then, in effect, are carrying around 'dead bytes' on amd64, for, reason?
> 
> That is, what is the 'win' in doing this ?
> 
> This is of no consequence for a handful of long doubles, but big arrays of
> long double
> 
> (This is just curiosity; I have found exactly one scientific calculation I
> needed to do whose precision improved using long doubles, a satellite
> orbital prediction over very long times)

(I am not a x86/amd64 expert and haven't followed lates architectures
closely, so take with a grain of salt)

There would be two options to do it differently on amd64:

 - make long double use emulation (i.e. don't use the FPU at all)
 - create a strange 12 (or maybe only 10) byte IEEE754 storage format

The former would make long double unreasonabley slow while the latter would
break alignment restrictions for some instructions.

Maybe one of the next generations of the instruction set gets a reasonable
FPU mode to do better long doubles.

Martin


Re: Error in returned value of sizeof(long double) in amd64?

2024-07-07 Thread Michael Cheponis
Thank you.

We, then, in effect, are carrying around 'dead bytes' on amd64, for, reason?

That is, what is the 'win' in doing this ?

This is of no consequence for a handful of long doubles, but big arrays of
long double

(This is just curiosity; I have found exactly one scientific calculation I
needed to do whose precision improved using long doubles, a satellite
orbital prediction over very long times)


-Mike


On Fri, Jul 5, 2024 at 9:35 PM Martin Husemann  wrote:

> On Fri, Jul 05, 2024 at 07:13:05PM -0700, Michael Cheponis wrote:
> > sizeof(long double) reports 16 in both amd64 and arm64.  I think that
> amd64
> > uses 80-bit long double floats, and arm64 uses 128-bit long double
> floats.
> > See enclosed code.
>
> The storage size of a long double is one thing, but the exact format
> used in calculations may vary.
>
> On amd64:
>
> > cc -dM -E - < /dev/null | fgrep LDBL_MANT
> #define __LDBL_MANT_DIG__ 64
>
>
> On aarch64:
>
> > cc -dM -E - < /dev/null | fgrep LDBL_MAN
> #define __LDBL_MANT_DIG__ 113
>
> (use just LDBL in the fgrep to see more exact limits of the format in use)
>
> Martin
>


Re: Error in returned value of sizeof(long double) in amd64?

2024-07-05 Thread Martin Husemann
On Fri, Jul 05, 2024 at 07:13:05PM -0700, Michael Cheponis wrote:
> sizeof(long double) reports 16 in both amd64 and arm64.  I think that amd64
> uses 80-bit long double floats, and arm64 uses 128-bit long double floats.
> See enclosed code.

The storage size of a long double is one thing, but the exact format
used in calculations may vary.

On amd64:

> cc -dM -E - < /dev/null | fgrep LDBL_MANT
#define __LDBL_MANT_DIG__ 64


On aarch64:

> cc -dM -E - < /dev/null | fgrep LDBL_MAN
#define __LDBL_MANT_DIG__ 113

(use just LDBL in the fgrep to see more exact limits of the format in use)

Martin


Error in returned value of sizeof(long double) in amd64?

2024-07-05 Thread Michael Cheponis
sizeof(long double) reports 16 in both amd64 and arm64.  I think that amd64
uses 80-bit long double floats, and arm64 uses 128-bit long double floats.
See enclosed code.

What am I misunderstanding?
-Mike

amd64 gives: 9 is 8.91326382620115964528, error is
0.08673617379884035472, sizeof(long double)=16
arm64 gives: 9 is 8.99986133, error is
0.00013867, sizeof(long double)=16

#include 
#include 
int main(){
  // Compute:  arcsin (arccos(arctan(tan(cos(sin (9))argument is in
degrees

  long double pi =
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679L;
  long double x,y,z,ans;

  x = pi / 20.0L; // 9 degrees is pi/20
  y = tanl(cosl(sinl(x)));
  z = asinl(acosl(atanl(y)));

  ans = z * 180.0L / pi;  // Convert to degrees:  rads * 180/pi

  printf("9 is %38.36Lf, error is %38.36Lf, sizeof(long double)=%ld\n",
ans,9.0L-ans,  sizeof(long double));
}