in reply to Re: Cygwin perl and (internal) numeric representations.
in thread Cygwin perl and (internal) numeric representations.

Then again perl has been compiled with -Duse64bitint if that makes any difference.

Yes ... it probably does make a difference. I had missed that Cygwin's perl was also compiled with use64bitint.

Does it make sense to build perl with use64bitint, for a 32-bit machine, with $Config{longsize} set to 4 ? My Cygwin perl certainly isn't giving me 64-bit int handling capability. As with my other perls, only integers up to 53 bits can be handled accurately.

Anyway, my problem is that the following xs code is not portable:
long i; if(SvIOK(a)) i = SvIV(a);
On my Cygwin perl I need to:
double d; if(SvIOK(a)) d = SvNV(a);
or perhaps (untested):
long long ii; if(SvIOK(a)) ii = (long long)SvIV(a);
I guess I just need to rethink what I'm trying to do.

Thanks parv.

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: Cygwin perl and (internal) numeric representations.
by parv (Parson) on Nov 26, 2006 at 05:47 UTC

    Happy to help, Rob, not that I could help with your XS problem.

    As to your question about using 64-bit integers on 32-bit machine, well that allows to exceed 2**32 :) (or, create situations like yours). Speaking of which ... a small thread on Google.

      As to your question about using 64-bit integers on 32-bit machine, well that allows to exceed 2**32

      Yes, but I can use integers up to 53 bits (before losing precision) on perls that haven't been compiled with use64bitint ... and on this Cygwin perl 5.8.7 I still only get integers up to 53 bits (before losing precision). So, in this instance, the use64bitint has achieved nothing.

      My first reading of that thread you linked to leads me to believe that use64bitint should provide 64 bits on perl 5.8 (but is guaranteed only to provide 53 bits on perl 5.6). But, since the Cygwin perl is 5.8.7, use64bitint should be providing the full 64 bits ..... I'll have to go back and go through that Google thread carefully.

      Thanks for steering me back onto the track.

      Cheers,
      Rob