returns a number formatted with commas representing the standard thousands, millions, billions separations in a number
usage: /comma number or $comma number
Updated to account for updated knowledge. Also allows for decimals in the number.
alias comma {
$iif($1 !isnum,echo -a Number required,$iif($isid,return,echo -a) $+($bytes($int($1),b),$calc($1 - $int($1))))
}
First there was an error when using it to sart with. There was a \" ) \" missing.
alias comma {
$iif($1 !isnum,echo -a Number required,$iif($isid,return,echo -a)) $+($bytes($int($1),b),$calc($1 - $int($1)))
}
When I added the missing \" ) \" it did not work right. It added a \" 0 \" to the end of every number. Examples below.
/comma 5 -> 50
/comma 50 -> 500
/comma 500 -> 5000
/comma 5000 -> 5,0000
There is an error in the description, where it says it works with atleast 50 numbers. Try this:
//echo -a $bytes(99999999999999999,b)
Result: 100,000,000,000,000,000
$bytes has trouble with rounding at 16 digits, and over 17 it start screwing up severly.
Try:
//echo -a $bytes(10000000000000000000000000,b)
Result:
10,000,000,000,000,001,000,000,000
See that 001 in the forth to last trio of digits?
That\'s why I made that $comma identifier, it gives support for an unlimited amount of numbers, as long as it\'s within the string too long limit.
general nice code, a few tips though: the variable %b isnt needed, you can just paste that into %c. Also (and this is something to keep in mind) dont double VAR a variable (this also means, dont use VAR in a loop). declare all the vars in the beginning like:
var %comma = $1, %c
and dont use any more var commands
anyway good work