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

Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.

## That implies... (Score:2)

...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?

## Re: (Score:2)

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

## Re: (Score:2)

If you're prepared to limit the input to 32 bit integers you can probably just change the

`long long`

to`long`

in the prototype of Miller(). It should still use`long long`

internally.To be more strictly correct you could use the output of

as the type of that argument. That will be

`long`

for 32 bit Perl and`long long`

for 64 bit Perl.And if you want to be really sneaky write a version that bypasses XS type mapping and correctly handles Math::BigInt objects :)

## Re: (Score:2)

Or, am I missing a point?

## Re: (Score:2)

No, I think you're quite right :)

This little program:

prints 53.

So Ovid - make that argument a double and then cast it to a long long inside the function.

## Re: (Score:1)

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:

and the Miller function becomes

Caveat: obviously, if you put something other than a number in p_as_str, things will go awry. Also, different platforms (e.

## Re: (Score:1)

strtoll()...## The Updated AKS primality test is slow? (Score:1)

http://en.wikipedia.org/wiki/AKS_primality_test [wikipedia.org]

The key significance of AKS is that it was the first published primality-proving algorithm to be simultaneously general, polynomial, deterministic, and unconditional. Previous algorithms have achieved any three of these properties, but not all four.I haven't seen an implementation (in perl or otherwise), but I thought it put to bed the problem of determining if a number was prime or not. The real problem is factorizing a composite

## Fast primality testing with Pari (Score:1)

If you're after a fast way of checking for prime numbers from Perl, then it's hard to go past PARI/GP [u-bordeaux.fr], which has a Math::Pari [cpan.org] interface. With the generation of large primes, strong random numbers, support for integers up to (2^29)^29 out of the box, and a host of other math functions, Pari is essentially crack for number theorists. It provides both isprime() [u-bordeaux.fr] and ispseudoprime() [wikipedia.org] functions.

There's also a brief mention of using Math::Pari for primality testing on perlmonks [perlmonks.org].

Cheerio,

Paul