Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: Fun with duff's device and AUTOLOAD

by ambrus (Abbot)
on Feb 25, 2004 at 21:41 UTC ( #331835=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Fun with duff's device and AUTOLOAD
in thread Fun with duff's device and AUTOLOAD

Maybe I wasn't clear in the explanation.

$#="%c";print 65; should not print an A. It pushes 65.0 (a double) and "%x" on the C stack, and calls sprintf. Then sprintf sees "%c", so tries to pop an int from the stack. 65.0 is represented as the bytes (00 00 00 00 00 40 50 40)hex, but an int is just 4 bytes so it pops (00 00 00 00)hex which is 0 as an int so it prints a nul char. (On sparc, however, it will get (40 50 40 00)hex, which is 67437568, so it will either print a null character or a multibyte character sequence corresponding to unicode chr 67437568, depending on the version of Perl.)

Dlugosz, I guess your cpu is an x86, correct me if it isn't.


Comment on Re: Re: Re: Fun with duff's device and AUTOLOAD
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://331835]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-09-23 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (219 votes), past polls