Your value is 2**53-1, not because it's the biggest 32bit Integer value, but because Perl automatically swaps to floating point with a 53 bit mantissa if the 32 bits are exceeded (see Double-precision floating-point format and perlnumber )

The max value for 64 bit representation will be about 2**63-1, because you need one bit for the sign in signed integers.

This has already been discussed many times.

NB: all values probably off by one, (UPDATED -1 because one slot will be occupied by zero.)

I'm not going to look up the correct values for you, if you're too lazy¹ to supersearch or Google, so am I.

FWIW: Your linear search is not terribly clever, use a binary search and you'll have finished before pronouncing the s in stupid.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

¹) quote: > "stored in IEEE-754 format internally. Whatever that means."


In reply to Re: Largest integer in 64-bit perl by LanX
in thread Largest integer in 64-bit perl by harangzsolt33

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.