By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,834 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,834 IT Pros & Developers. It's quick & easy.

Number formatting doubt

P: 89

I get to get a number 3076569 along a flow in my program which needs to be displayed in a html page. How to change the formatting into 3,00,76,569 as human readable? Any staraight forward method or I need to count the digit and out a comma? Thanks.
Nov 19 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 4,059
perl add commas to number ;)

hehehe.... just noticed my code snippet on Daniweb comes up second in that google search. :^D
Nov 19 '08 #2

Expert 100+
P: 174
I guess i will post the code for this place but Kevin also gave you the answer.

Expand|Select|Wrap|Line Numbers
  1. $num = 3076569;
  2. $num = Format($num);
  4. sub Format {
  5.    ($a = shift) =~ s/\G(\d{1,3})(?=(?:\d\d\d)+(?:\.|$))/$1,/g; 
  6.    return $a; 
  7. }
  9. print "$num";
Nov 20 '08 #3

P: 89
Yes Thanks. I got Kevin's code.
Nov 21 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.