20180324, 06:49  #1 
Mar 2018
11_{16} Posts 
nextprime function is spooked by leading zero.
An example on Windows 7:
Code:
C:\Users\Christopher\Downloads\yafu1.34>yafux64 "nextprime(723391033893233, 0)" ans = 723391033893197 Code:
C:\Users\Christopher\Downloads\yafu1.34>yafux64 "nextprime(0723391033893233, 0)" ans = 2 
20180325, 03:26  #2 
"William"
May 2003
New Haven
3·787 Posts 
Is it the "leading zero means the number is octal" issue? And the number isn't a valid octal number, so "string to integer" returns zero?

20180326, 00:22  #3  
Mar 2018
11_{16} Posts 
@wblipp
Good point, but in the docfile.txt of YAHU 1.34 it says Quote:


20180326, 02:13  #4  
"Ben"
Feb 2007
D2B_{16} Posts 
Quote:
Chances are it will be an easy fix, but also likely is that the fix will only appear in source revision, not a new released version. Can you build from source? 

20180326, 02:33  #5 
Mar 2018
17 Posts 
Thanks @bsquared. I can't build from source, but this is not an urgent fix for me as I have amended that "other program" to remove the leading zero.

20180327, 13:59  #6 
"Ben"
Feb 2007
110100101011_{2} Posts 
I looked at the code and here is what's happening. Yafu's parser looks at the input and decides that yes, 0723391033893233 is a number (not a variable name or function). Whereupon it hands the number to gmp's mpz_set_str function; I've been using that function with base 0, meaning autodecode the base. Gmp's autodecoder just needs a leading 0 to decide octal, but the number is not octal so the call fails. Wblipp was right.
Yafu's parser correctly decoded decimal (it looks for leading 0o for octal), so I if change anything I could use the base decoder in my parser instead of relying on gmp. However, 0o is not standard notation for octal... a single leading 0 is historically the way to represent them. So Gmp's interpretation is the correct one. I'll leave things as they are except I will add a printed warning if the conversion fails. 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Religious extremism leading to conflict and slaughter: how to handle this?  BrianE  Soap Box  15  20140516 03:12 
nextprime() appears to be limited...  EdH  YAFU  7  20130318 22:09 
Leading Edge  Primeinator  Information & Answers  9  20100625 07:36 
Fixed leading bits in RSA modulus, vs NFS  fgrieu  Factoring  7  20090923 11:45 
Graph of leading edge of LL testing (and doublechecking) over time  GP2  Data  10  20031117 14:55 