Thank you haukex this is a good explanation.
In a sense am I being a little bit confused around what Devel:Peek is telling me, bearing in mind I am using a 5.14 version.
$n = unpack "C", pack "B", 128;
&print_val;
$n += $n;
&print_val;
#output
#SV = IV(0xe28558) at 0xe2855c
# REFCNT = 1
# FLAGS = (PADMY,IOK,pIOK)
# IV = 128
# ###
#SV = IV(0xe28558) at 0xe2855c
# REFCNT = 1
# FLAGS = (PADMY,IOK,pIOK)
# IV = 256
# ###
These are actually UV values then? but Perl is storing them as IV's. and the sum at the microprocessor level, adding 128 to itself, is carrying out a binary addition of a natural number.
I have only just found out about two's complement a couple of weeks ago, and I'm not sure where I stand on that just yet.
-
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.
|