Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • ...that you're trying to move a long long between C and Perl. Do you need to do that? Can't the long longs just live inside the C?

    It's probably not too hard to write the code to thunk between long long and Math::BigInt - would that help?

    • I don't know since my C and XS skills are so poor. The relevant bit of XS code is this:

      #include "EXTERN.h"
      #include "perl.h"
      #include "XSUB.h"
      #include <stdbool.h>

      #include "ppport.h"

      /* This function calculates (ab)%c */
      int modulo(int a,int b,int c){
          long long x=1,y=a; // long long is taken to avoid overflow
                             // of intermediate results
          // skipping implementation
      }

      /* this function calculates (a*b

      • If (and its a big if) you need the full 64 bit input, might I suggest passing the number as a string/PV, then doing a strtoll() or its equivalent in your non-XS functions ?

        Then your XS looks like:

        void Miller(char *p, int iteration)

        and the Miller function becomes

        bool Miller(char *p_as_str,int iteration){
            long long p = stroll(p_as_str);
            if(p<2){

        Caveat: obviously, if you put something other than a number in p_as_str, things will go awry. Also, different platforms (e.g., Windows) have variants of the stroll().