when i try to do print("0x30"+0); at home, perl says 1.5, while at work it says 48. i was using perl 5.6.0 in both cases and in both cases i was expecting to get 0. i tried it with perl 5.005_03 and the result was '1.5' again. print("030"+0); prints 30, not 24. with warnings on it even gives the 'non-numeric' warning, but then extrapolates it to number anyway. i even somehow can understand the 0x30 -> 48, but 0x30 -> 1.5 is far beyond my comprehension. print("0x37"+0,"\n"); gives the even more surprising result 1.71875.
can somebody shed some light?
-
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.
|