develooper Front page | perl.perl5.porters | Postings from June 2021

Re: quadmath with 32 bit ints

Thread Previous | Thread Next
From:
Peter John Acklam
Date:
June 11, 2021 06:47
Subject:
Re: quadmath with 32 bit ints
Message ID:
CAEvoY41y0Ge24YMJL8nZ0eCLau4rGLUo04Xoe6EL+bMURFtTKw@mail.gmail.com
tor. 10. jun. 2021 kl. 16:21 skrev sisyphus <sisyphus359@gmail.com>:
>
> I also spent some time trying (unsuccessfully) to have the existing logic handle this case.
> Eventually, I decided that, given the rarity of perls with 4-byte IVs and 16-byte NVs, we could
> get away with simply nominating values of $e and $int that work.

I got something working. It stops with $e = 16 and $use_int = 0. Even
with $e = 17, all the values are within the range of what can be
represented exactly with 128 bit floats, but certain things fail. For
instance, I expected the following to return 1

$ perl -wle 'print( (2**113 - 1) % 2)'
0

I guess it has to do with how the % operator is implemented. I haven't
dug into it. POSIX::fmod() gets it right, though

$ perl -MPOSIX -wle 'print fmod(2**113 - 1, 2)'
1

but I don't think it's worth requiring the POSIX module just to get $e
= 17 rather than $e = 16.

Peter

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About