Offer Kaye wrote:
> On 4/11/06, John W. Krahn wrote:
>>>This is probably trivial, but I couldn't find a mention of this
>>>anywhere - why do the following 2 code lines produce different
>>>results?
>>>>perl -e 'printf "%d\n" ,0xffff_ffff'
>>>-1
>>>>perl -e 'print 0xffff_ffff , "\n"'
>>>4294967295
>>perldoc perlnumber
> 
> Thanks for the pointer, I guess you wanted me to see the "All the
> operators which need an argument in the integer format treat the
> argument as in modular arithmetic" sentence.

I thought that that might be the documentation that you were looking for.

> But why is "print" behaving differently? I.e., why is the 0xffff_ffff
> not treated as a number?

0xffff_ffff is treated as a number because it is a number, the number
4294967295 as an unsigned integer and -1 as a signed integer.

perldoc -f sprintf
[snip]
                  %d   a signed integer, in decimal
                  %u   an unsigned integer, in decimal


Use the %u format if you want the unsigned integer representation.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to