thank you ww
I do wish I knew how to copy error messages without having to write them down. I use strawberry perl, and the console gives the error message without an opportunity to copy it. I just assumed that if anyone ran the code they would get the same message.
it reads something like:
next_prime <n> : input '1.84467440869813e+019' must be a positive integer at c:\subdirectory... line 20 | [reply] |
This is a pretty sketchy reply, but please forgive that as it's been a long time since I set up a "Command Prompt" to allow highlighting a word, phrase, para or whatever, so that by hitting RETURN (aka ENTER) I dump the highlighted data into a buffer which can then be pasted into another application -- say, my text editor, a calc sheet, etc.
Laurent_R describes an ad hoc approach but you can make your Win32 console more manageable (editable) by opening a "Command Prompt"; right clicking on the title bar (including the icon at the top left which is inside the bar) and adjusting the various options under "Properties."
Addtl thoughts: check the quickedit and insert boxes in the first tab (options), and, often, you'll find it useful to increase the window and screenbuffer dimensions in the "layout" tab.
Edit 2: This is from a Win7 Pro box:
This is perl 5, version 18, subversion 4 (v5.18.4) built for MSWin32-x86-multi-thread-64int
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
Binary build 1805 299195 provided by ActiveState http://www.ActiveState.com
Built Jul 20 2015 16:07:57
I (eventually) see this message, error and output:
1141975.pl
Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::Calc at 1141975.pl line 4.
Parameter '1.84467440869813e+019' must be a positive integer at 1141975.pl line 20.
| [reply] [d/l] |
| [reply] |
input '1.84467440869813e+019' must be a positive integer
A rather odd message, given that '1.84467440869813e+019' is a positive integer value.
I think next_prime() must be looking for an IV or UV, but the value about which it complains is too large to fit into an IV/UV and has been converted to an NV (double precision float).
I can't quite reconcile the error message you've provided with the Math::Prime::Util (version 0.53) source.
Perhaps I was looking in the wrong place, or perhaps I was looking at the wrong version.
If you're not already using 0.53, consider upgrading to it - it might accept such values (dunno).
Also note that, although your script loads the Math::BigFloat module, I can't see any Math::BigFloats being used anywhere in your code.
And I don't think next_prime() would accept a Math::BigFloat input, anyway - though I haven't tested.
Cheers, Rob
| [reply] |
The issue is that the module got an NV, not a UV, IV, or numerical string. Sure, it can convert it, but it will probably not be what the caller intended. The source for almost all functions call _validate_int() on inputs, which is where the error message occurs.
Edit: The value it dies on for me has exceeded 64 bits, so there is no way the module would get the intended input. Better to die than give a wrong answer.
In theory to work with larger inputs, we should be doing the input calcs as BigInt (or Math::GMP or Math::GMPz, etc.) to make sure they're correct and scale past 64-bit, then do the gap/log($num) making sure the inputs are BigFloat.
The reason we wouldn't want to let $num be an NV for the log calc is that these scripts should scale to $num values of 20k+ digits, which won't fit in a double or long double.
| [reply] |
| [reply] |