Log for attempted build of libmath-mpfr-perl_3.17-1 on m68k (dist=unstable)

sisyphus1 at optusnet.com.au sisyphus1 at optusnet.com.au
Sat May 4 08:34:58 UTC 2013



-----Original Message----- 
From: Daniel Kahn Gillmor

> On Sat 2013-05-04 00:27:36 -0400, sisyphus1 at optusnet.com.au wrote:
>
> > Could someone try this script (on one of the big-endian machines) and 
> > send
> > me the output, please :
>
> this is on a powerpc machine:
>
> 0 dkg at reason:~/src/endianness$ cat > test.c
> #include <stdio.h>
> #include <mpfr.h>
>
> int main(void) {
> long long int a[9] = {80LL, 580LL, 1000001LL, 5003607LL, 2107083607LL, 
> 2147483647LL, 2140000000LL, 1454735360LL, 1868562432LL};
> long long int b[9] = {1342177280LL, 1140981760LL, 1094848256LL, 
> 1465469952LL, 1468766077LL, 4294967167LL, 13602175LL, 8435030LL, 24687LL};
> int i;
>
> for(i = 0; i < 9; ++i) {
>   printf("Want %llu\n", a[i]);
>   mpfr_printf("Got  %Pu\n\n", b[i]);
> }
>
> for(i = 0; i < 9; ++i) {
>   printf("Want %llu\n", a[i]);
>   mpfr_printf("Got  %Pu\n\n", a[i] << 32);
> }
>
> return 0;
> }
> 0 dkg at reason:~/src/endianness$ gcc -lmpfr -g -o test test.c
> 0 dkg at reason:~/src/endianness$ ./test
> Want 80
> Got  4153774080
>
> Want 580
> Got  4153774080
>
> Want 1000001
> Got  4153774080
>
> Want 5003607
> Got  4153774080
>
> Want 2107083607
> Got  4153774080
>
> Want 2147483647
> Got  4153774080
>
> Want 2140000000
> Got  4153774080
>
> Want 1454735360
> Got  4153774080
>
> Want 1868562432
> Got  4153774080
>
> Want 80
> Got  4153774080
>
> Want 580
> Got  4153774080
>
> Want 1000001
> Got  4153774080
>
> Want 5003607
> Got  4153774080
>
> Want 2107083607
> Got  4153774080
>
> Want 2147483647
> Got  4153774080
>
> Want 2140000000
> Got  4153774080
>
> Want 1454735360
> Got  4153774080
>
> Want 1868562432
> Got  4153774080
>
> 0 dkg at reason:~/src/endianness$
>
> hth,

Nope ... looks like we're in territory that needs to be avoided altogether.
(At least we now know how to avoid a "0" result ;-)

10 minutes later and I think I have a solution.
Instead of doing:
Rmpfr_printf("%Pu\n", Rmpfr_get_prec($op);

I can document that we must do:
Rmpfr_printf("%Pu\n", prec_cast(Rmpfr_get_prec($op));

where prec_cast() returns an object that encapsulates an actual mpfr_prec_t.
Then I also change the s/sn/f/printf functions so that, if they receive one 
of these objects, then the first thing they do is to extract the mpfr_prec_t 
value from that object and pass that extracted mpfr_prec_t value on.

That involves a bit of XS coding ... but at least it should work everywhere 
... assuming that one can do everywhere (eg):

IV a = 24687;
mpfr_prec_t b = (mpfr_prec_t) a;

and have 'b' contain a value of 24687.

I guess there'll be a compiler warning (about possible loss of precision) 
associated with that whenever the IV is larger than the mpfr_prec_t, but it 
should still work as expected, shouldn't it ?

Anyway, I'll get to it, and see how it goes.

Cheers,
Rob






More information about the pkg-perl-maintainers mailing list