Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie perl number format

Status
Not open for further replies.

bluegroper

Technical User
Dec 12, 2002
407
AU
Hey forum
I'm using the following to format some numbers :
Code:
$data=sprintf("%.2f",$data);
How do I also include commas after every 3 digits from the right of the values in $data ?
Much TIA's
 
Hey bluegroper,

Was wondering what sort of work you are doing this for? is it coursework?

I'm not quite sure what you mean. From your script I can see that you are producing a number with 2 decimal places i.e. 43.22

you said "How do I also include commas after every 3 digits from the right of the values in $data ?"

Did you mean a number like this 333,333,333.22 or a number like this 43.224,333,444

Its always helpful if you post an example of what you want to produce
 
it's covered in the perl FAQs.

How-can-I-output-my-numbers-with-commas

You should familiarize yourself with the perl FAQs, there is lots of useful information containted within.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Chris
It is money amounts, so I was meaning something like 12,345.60 rather than 12345.6

Kevin
Shall try sub commify or format_number.

Cheers all, and thx for clues.
-BG

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top