Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Hexadecimal representation of pi

by ambrus (Abbot)
on Mar 07, 2006 at 13:53 UTC ( #534919=note: print w/replies, xml ) Need Help??


in reply to Hexadecimal representation of pi

As you're golfing, there are a few trivial modifications that can save a few characters (update: 4 characters). Omit the semicolons after the sub definitions and for loops, and change ($/*=16)%=O to $/=$/*16%O.

$|=print 3.2;sub O{8*($@-$_)+(1,4,5,6)[$:]}sub o{(-4,2,1,1)[$:]/O}while($,=++$@){for$:(0..3){ for (0..$@) {for$" (($/=1) ..$_){ $/=$/* 16%O} $,-=$/ *o}$, -=16** $_*o for-6..- 1}printf "%x",$,* 16%16}

Replies are listed 'Best First'.
Re^2: Hexadecimal representation of pi
by weixi (Novice) on Mar 07, 2006 at 15:04 UTC
    Thanks for the hints!

    Now that you made me aware of the semicolons after the sub definitions, I am really stunned I didn't realize those myself.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://534919]
help
Chatterbox?
[karlgoethebier]: shmem:Ach so. Bollerwagen ist eigentlich was für Kinder. Bei uns fahren sie mit Traktoren und Feuerwehrwagen rum...
[shmem]: karlgoethebier: here abouts people are sitting in big tents, gulp beer and ingest badly scorched chicken and sausages while (not) listening to afwul musik
[shmem]: *awful
[choroba]: panem et circenses
[karlgoethebier]: shmem: Yes. I didn't go to the firefighters party just 500 yards from my home this year...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2017-05-25 12:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?