Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Answer: How do I print a large integer with thousands separators?

by Jaap (Curate)
on May 17, 2005 at 11:36 UTC ( #457747=categorized answer: print w/replies, xml ) Need Help??

Q&A > data formatting > How do I print a large integer with thousands separators? - Answer contributed by Jaap

Here's a simple (and quite fast) one using substr:

my $number = 132452345; for ( my $i = -3; $i > -1 * length($number); $i -= 4 ) { substr( $number, $i, 0 ) = ','; }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2020-10-25 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (248 votes). Check out past polls.

    Notices?