From WikiChip
Editing mirc/identifiers/$bytes
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{mirc title|$bytes Identifier}}'''$bytes''' allows you to format | + | {{mirc title|$bytes Identifier}}'''$bytes''' allows you to format any number that you pass into various byte forms. |
− | |||
== Synopsis == | == Synopsis == | ||
− | <pre>$bytes(<N>[, | + | <pre>$bytes(<N>[,bkmgt3d])[.suf]</pre> |
+ | |||
== Parameters == | == Parameters == | ||
Line 13: | Line 13: | ||
* '''g''' - Comma, and decimal-formats the number for [[gigabytes]]. | * '''g''' - Comma, and decimal-formats the number for [[gigabytes]]. | ||
* '''t''' - Comma, and decimal-formats the number for [[terabytes]]. | * '''t''' - Comma, and decimal-formats the number for [[terabytes]]. | ||
− | |||
* '''3''' - Returns the result in 3-digit format. | * '''3''' - Returns the result in 3-digit format. | ||
* '''d''' - Returns the value whilst retaining decimal point values. | * '''d''' - Returns the value whilst retaining decimal point values. | ||
Line 20: | Line 19: | ||
== Properties == | == Properties == | ||
− | * '''.suf''' - Returns the formatted bytes with the proper suffixes, which are: '''B''', '''KB''', '''MB''', '''GB''', '''TB | + | * '''.suf''' - Returns the formatted bytes with the proper suffixes, which are: '''B''', '''KB''', '''MB''', '''GB''', and '''TB''' |
− | |||
== Examples == | == Examples == | ||
'''Echo a large number with comma format to the active window''' | '''Echo a large number with comma format to the active window''' | ||
Line 30: | Line 28: | ||
<source lang="mIRC">//echo -a $bytes(10000000000,g).suf</source> | <source lang="mIRC">//echo -a $bytes(10000000000,g).suf</source> | ||
− | When $bytes formats the number without being forced to use a specific suffix, it defaults to choosing a suffix which allows it to be presented as a number having | + | When $bytes formats the number without being forced to use a specific suffix, it defaults to choosing a suffix which allows it to be presented as a number having 3 number to the left of the decimal, and limits the fraction as no more than 2 digits. It doesn't display the suffix unless the .suf property is used. If the '3' switch is used, the display is modified so that the digits of the fraction also count as part of the 3 numbers, which can result in the fraction being shortened or even eliminated in order to limit the combined digit total to 3. The number is shortened into units of 1024's not 1000's. |
Because of float rounding behavior, you cannot count on a completely accurate rounding if the rounding is chopping the '5' digit from the tail end of the fraction. Even for rounding of numbers to the left of the decimal, you should view these results only as an approximation. | Because of float rounding behavior, you cannot count on a completely accurate rounding if the rounding is chopping the '5' digit from the tail end of the fraction. Even for rounding of numbers to the left of the decimal, you should view these results only as an approximation. | ||
Line 41: | Line 39: | ||
The behavior of recognizing $bytes(1e4,b) as ten thousand is probably an incidental behavior similar to the way that other identifiers like $int and $abs also recognize scientific notation. | The behavior of recognizing $bytes(1e4,b) as ten thousand is probably an incidental behavior similar to the way that other identifiers like $int and $abs also recognize scientific notation. | ||
− | $bytes is not intended to handle extremely huge numbers, since the greatest suffix it recognizes is | + | $bytes is not intended to handle extremely huge numbers, since the greatest suffix it recognizes is TB (terabytes), at which point it stops preventing the result from being presented with fewer numberic digits. |
− | + | == Compatibility == | |
+ | {{mIRC compatibility|6.17}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== See Also == | == See Also == | ||
* {{mIRC|$abs}} | * {{mIRC|$abs}} | ||
* {{mIRC|$base}} | * {{mIRC|$base}} | ||
* {{mIRC|$calc}} | * {{mIRC|$calc}} | ||
+ | {{mIRC identifier list}} | ||
+ | |||
+ | [[Category:mIRC identifiers|bytes]] |