In a sense am I being a little bit confused around what Devel:Peek is telling me
If you want to dive into that rabbit hole, see perlguts and the rest of the internals documentation, although be warned, that's not light reading.
These are actually UV values then? but Perl is storing them as IV's.
Those values will fit fine into a signed integer, so as per dave_the_m's explanation, Perl has no need to upgrade them to a UV. It might be interesting to note that Perl can store pretty big integer values. As per ikegami's post here:
- Largest integer value that can be stored as a signed integer: ~0 >> 1 (on my machine: 9,223,372,036,854,775,807), and the smallest: -(~0 >> 1)-1
- Largest integer value that can be stored as an unsigned integer: ~0 (on my machine: 18,446,744,073,709,551,615)
- All integer values from 0 to this number can be stored without loss as a floating point number: $Config{nv_overflows_integers_at} (on my machine: 9,007,199,254,740,992)
two's complement
One of the things that really helped it click for me back then was this graphic, along with looking at different 2's complement mathematical operations (Update 2: as I showed in my reply below):
0
-1 0000 1
1111 0001
-2 2
1110 0010
-3 3
1101 0011
-4 4
1100 0100
-5 5
1011 0101
-6 6
1010 0110
-7 7
1001 -8 0111
1000
Update: In the graphic I accidentally wrote "8" when it should have been "-8", sorry, fixed.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|