Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Re: Separating big numbers with commas

by Anonymous Monk
on Sep 05, 2001 at 02:07 UTC ( #110179=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Separating big numbers with commas
in thread Separating big numbers with commas

Heh, add a couple more decimal places and it will fail (unless you consider commas after the decimal point to be allowable):

#!/usr/bin/perl -w use strict; my $number='12345.67890'; # with commas, should be: 12,345.67890 print "N=$number\n"; $number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; print "N=$number\n";

Output:

N=12345.67890 N=12,345.67,890

Looks funky to me.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-05-27 06:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (153 votes). Check out past polls.

    Notices?