mIRC Home    About    Download    Register    News    Help

Print Thread
J
Joe_Dean
Joe_Dean
J
I have a stats script that is always collecting data and returns large numbers every time. The numbers it returns appear as just numbers with no commas. So instead of the default '100000' (for example), is there a small snippet I could add that will automatically put a comma, starting from right to left, for every 3 digits? Example:

1000 - 1,000
10000 - 10,000
100000 - 100,000
1000000 - 1,000,000
etc.

Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
Try this:

//echo -a $bytes(1000000.001,bd)

Retains decimal values, if supplied.

-genius_at_work

Joined: Dec 2002
Posts: 2,002
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,002

Try using the $bytes identifier with the b option.

//echo -a $bytes(1000000,b) <-- Like this
1,000,000 <-- Like this

J
Joe_Dean
Joe_Dean
J
Oh that's nice, real good. Thanks guys. laugh

M
MeStinkBAD
MeStinkBAD
M
You would think such an identifier would have a better name than "$bytes"...

Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
That's because the identifier is intended to be used for formatting a number of bytes into kilobytes, megabytes, etc. - the comma formatting is just a side-effect usage.


Link Copied to Clipboard