From WikiChip
Difference between revisions of "mirc/identifiers/$round"
Maroonbells (talk | contribs) (Add'l examples) |
(→Parameters) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
== Synopsis == | == Synopsis == | ||
− | < | + | <source lang="mIRC">$round(N,D)</source> |
== Parameters == | == Parameters == | ||
− | * '''N''' - The number you want to round, can be negative. | + | * '''N''' - The number you want to round, can be negative. |
− | * '''D''' - The number of decimal to round | + | * '''D''' - The number of decimal to round but if D is 0, it rounds up to the nearest whole number, if $null, number is not changed |
+ | |||
+ | You can use the letter 'e' or 'd' as *10^N for '''N''' and '''D''', $round(5e6,2) = $round($calc(5*10^6),2) | ||
+ | |||
+ | |||
+ | '''Note''': mIRC's floating point accuracy is currently at 6 places, so D has no effect outside the range 0-6. Rounding to D fractional digits can show fewer than D digits because it does not pad trailing zeroes. | ||
− | |||
− | |||
== Properties == | == Properties == | ||
None | None |
Latest revision as of 13:42, 23 April 2020
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$round returns a floating point number rounded to a number of decimal.
Synopsis[edit]
$round(N,D)
Parameters[edit]
- N - The number you want to round, can be negative.
- D - The number of decimal to round but if D is 0, it rounds up to the nearest whole number, if $null, number is not changed
You can use the letter 'e' or 'd' as *10^N for N and D, $round(5e6,2) = $round($calc(5*10^6),2)
Note: mIRC's floating point accuracy is currently at 6 places, so D has no effect outside the range 0-6. Rounding to D fractional digits can show fewer than D digits because it does not pad trailing zeroes.
Properties[edit]
None
Example[edit]
//echo -a $round(4.98472,3) Even though $pi has 20 decimal places, all results limited to 6 places. Note that $calc also rounds to 6 places: //echo -a $pi calc: $calc($pi) round: $round($pi,7) result: 3.14159265358979323846 calc: 3.141593 round: 3.141593 Because of floating point translation to/from base 10, the result is not always the fraction expected: //var %i 1 , %list | while (%i isnum 1-100) { var %list %list $round(%i $+ .05 ,1) | inc %i } | echo -a round: %list result: round: 1.1 2 3 4 5 6 7 8.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1 16.1 17.1 18.1 19.1 20.1 21.1 22.1 23.1 24.1 25.1 26.1 27.1 28.1 29.1 30.1 31.1 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
Compatibility[edit]
Added: mIRC v5.1
Added on: 28 Aug 1997
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.