Closed p5pRT closed 20 years ago
This program:
$x = 2**32; print "\$x is $x\n"; print sprintf "\$x is %d\n"\, $x;
prints
$x is 4294967296 $x is -1
I think that the section on `sprintf' in the `perlfunc' manpage should document exactly what numeric conversion takes place. For example\, does %d always print the value modulo 2^32\, or does it depend on the operating system or architecture?
garethr@cre.canon.co.uk (Gareth Rees) wrote:
I think that the section on `sprintf' in the `perlfunc' manpage should document exactly what numeric conversion takes place. For example\, does %d always print the value modulo 2^32\, or does it depend on the %operating system or architecture?
An appeal to the ANSI spec would probably yield the answer\, which is that it defaults to native 'int' unless you've asked Perl to 'USE_64_BITS'.
To avoid having to appeal to a non-Artistic source of documentation\, I suggest the following addition. Note that I've altered 'flags' to 'characters' as well\, since some of the 'flags' mentioned are in fact conversion characters.
Migrated from rt.perl.org#940 (status was 'resolved')
Searchable as RT940$