mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
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,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Try this:

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

Retains decimal values, if supplied.

-genius_at_work

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

Try using the $bytes identifier with the b option.

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

Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
Oh that's nice, real good. Thanks guys. laugh

Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
You would think such an identifier would have a better name than "$bytes"...


Beware of MeStinkBAD! He knows more than he actually does!
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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.


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard