Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PerlPowerTools CPAN distribution.

Report information
The Basics
Id: 98905
Status: stalled
Priority: 0/
Queue: PerlPowerTools

People
Owner: Nobody in particular
Requestors: DANAJ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.002_02
Fixed in: (no value)



Subject: factor and primes are limited to 2^32
Both factor and primes check that the inputs are 10 or fewer digits and less than 2^32. It is unclear to me whether this is: 1) intentional behavior that should always be maintained for compatibility. or 2) sanity checking the range, and since 64-bit Perl didn't come until after these were written, 32-bit was hard coded. These are not hard to extend, albeit they're not super speedy for larger numbers, but Ben Tilly wrote some pretty nice code so not nearly as bad as one might expect. I've been playing with alternate primes implementations -- it can be easily sped up 2x for large bases, and I'm sure more than that if we accept lots of turmoil. For extra credit, we could even use Math::BigInt, but doing that for all inputs while maintaining decent speed might give too much bloat (at least for my coding it would).
Subject: Re: [rt.cpan.org #98905] factor and primes are limited to 2^32
Date: Mon, 15 Sep 2014 16:00:17 -0400
To: bug-PerlPowerTools [...] rt.cpan.org
From: brian d foy <bdfoy [...] cpan.org>
I think we could detect the numeric range and switch to bignum. I say go for it; slow right answers are better than fast no answers. :)
On Mon Sep 15 16:01:14 2014, BDFOY wrote: Show quoted text
> I think we could detect the numeric range and switch to bignum. I say > go for it; slow right answers are better than fast no answers. :)
That would be my thought as well. By the way, we can compare to the Perl programs factor.pl and primes.pl from Math::Prime::Util. They have more features and require a large module, but still useful for comparison. On a tangent, I may also change the factor output for inputs <= 1. It's different from GNU factor for 0 and 1 (0 is debatable, 1 looks like a mistake).
Subject: Re: [rt.cpan.org #98905] factor and primes are limited to 2^32
Date: Mon, 15 Sep 2014 17:01:57 -0400
To: bug-PerlPowerTools [...] rt.cpan.org
From: brian d foy <bdfoy [...] cpan.org>
Show quoted text
> On a tangent, I may also change the factor output for inputs <= 1. It's different from GNU factor for 0 and 1 (0 is debatable, 1 looks like a mistake).
The reference implementation was BSD. I don't particularly care how things are implemented as long as we can avoid unnecessary dependencies. We can certainly note the presence of Perl modules and advanced programs in the docs, and use modules if they are already installed. -- brian d foy <brian.d.foy@gmail.com> http://www.pair.com/~comdog/
On Mon Sep 15 17:02:48 2014, BDFOY wrote: Show quoted text
> > On a tangent, I may also change the factor output for inputs <= 1. > > It's different from GNU factor for 0 and 1 (0 is debatable, 1 looks > > like a mistake).
> > The reference implementation was BSD.
I deleted my text about /usr/games/factor from the bsd package matching, but that's not definitive regardless. Where's my 1990's BSD machine when I need it? The old NetBSD machine I have access to doesn't have factor installed. Looks like github has a BSD4.4 snapshot from 1993. The 0 oddball behavior is there, but as I suspected, our output for 1 is a typo (we output "1:1" instead of "1: 1"). DragonFlyBSD's repo indicates 0's behavior is "historical practice" confirming we leave it as is. Show quoted text
> I don't particularly care how things are implemented as long as we can > avoid unnecessary dependencies.
I was thinking, based on what is there, that these should be very low dependency (nothing outside of core unless absolutely necessary), and not overly complicated. primes and factor shouldn't *need* anything non-core. Show quoted text
> We can certainly note the presence of Perl modules and advanced > programs in the docs, and use modules if they are already installed.
That's a good point.
Subject: Re: [rt.cpan.org #98905] factor and primes are limited to 2^32
Date: Mon, 15 Sep 2014 17:42:35 -0400
To: bug-PerlPowerTools [...] rt.cpan.org
From: brian d foy <bdfoy [...] cpan.org>
The older PPT repos (and the initial version of mine) have copies of the BSD man pages and other notes. I removed most of that early on because I didn't feel like carrying all that stuff around. It's a big commit: 438c9e207ed2eed00d45f1d0e9263f73dea8546e The parent of that is 1b73b66f6af325162f9d8e7bed9c4bb96b490cf4, which should have all the old docs.