Note that there are some explanatory texts on larger screens.

plurals
  1. POBash Number Limit?
    primarykey
    data
    text
    <p>I asked <a href="https://stackoverflow.com/questions/13736745/bash-read-numbers-from-file-until-line-n">a question</a> earlier that involved pulling large primes from a text file and putting them into another file. It was supposed to grab every prime up to and including the first prime after 2^32, and for some reason this script stopped working.</p> <pre><code>#!/bin/bash n=4294967296 last=0 while read number do if [ $last -gt $n ] then break fi echo $number last=$number done &lt; primes.txt &gt; primes2.txt </code></pre> <p>It ended up looping through these 11 numbers:</p> <pre><code>4232004449 4232004479 4232004493 4232004509 4232004527 4232004533 4232004559 4232004589 4232004593 4232004613 004437 </code></pre> <p>The original file didn't have <code>004437</code> in it, and my bash will handle numbers over <code>8999999999999999999</code></p> <p>Does anybody have a clue as to why this happened?</p> <blockquote> <p>64-bit Ubuntu 10.04, 16GB RAM, 8-cores @ 3.60 GHz<br> GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)</p> </blockquote> <p><strong>Update:</strong></p> <p>After downloading and compiling the "fixed" bash provided by jfgagne and linking to it in my bash script, it errored out at the same exact spot. Using the significantly faster perl equivalent from my original prime question, I got some file sizes from ls -al:</p> <pre><code> 11 next_prime (just to make sure this was counting bytes accurately) 2147483659 primes2.txt 2147483670 one_too_many </code></pre> <p>2147483659 = 2^31 + 11</p> <p>The size of the next prime (<code>4232004631</code>) is 11 bytes This holds all primes up to <code>4232004613</code>. I also realized that the <code>004437</code> is coming from the end of the prime at the bottom of this error loop (<code>4232004437</code>). It seems like something is trying to advance, but stuck.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload