From WikiChip
Difference between revisions of "mirc/identifiers/$log"
(Created page with "{{mirc title|$log identifier}}'''$log''' returns the natural logarithm (base e) of a number. == Synopsis == <pre>$log(N)</pre> == Paramters == <span style="display: inline-...") |
Maroonbells (talk | contribs) (Add'l info) |
||
Line 1: | Line 1: | ||
{{mirc title|$log identifier}}'''$log''' returns the natural logarithm (base e) of a number. | {{mirc title|$log identifier}}'''$log''' returns the natural logarithm (base e) of a number. | ||
+ | 'e' is an irrational number whose digits begins with 2.718281828 | ||
+ | 'e' is the value where graphing the curve y=e^x has slope of X at every location along the curve. | ||
+ | The natural logarithm of the value N is the exponent X where e^X is the value N. $log(e) is 1, $log(1) is 0, $log of values between 0 and 1 are negative. Returns error for N=0 or N=negative. | ||
+ | |||
+ | There may be a rounding error due to mIRC preserving fractional digits to only 6 places. | ||
== Synopsis == | == Synopsis == | ||
Line 14: | Line 19: | ||
<source lang="mIRC"> | <source lang="mIRC"> | ||
//echo -a $log(50) | //echo -a $log(50) | ||
+ | result: 3.912023 | ||
+ | //echo -a $calc(2.718281^3.912023) | ||
+ | result: 49.99994 | ||
</source> | </source> | ||
+ | <source lang="mIRC"> | ||
+ | //var %e = 2.718281828 , %begin_balance = 10 , %interest_rate = .07 , %years = 20 | echo -a As compounding interval becomes shorter, ending balance approaches $ $+ $calc(%begin_balance * (%e ^(%interest_rate * %years))) | ||
+ | |||
+ | You can use $log to find the base-X logarithm for any value N with $calc( $log(N) / $log(X) ) | ||
+ | //echo -a base-3 logrithm of 50 is $calc( $log(50) / $log(3) ) | ||
+ | result: base-3 logrithm of 50 is 3.560878 | ||
+ | //echo -a $calc( 3 ^ 3.560878 ) | ||
+ | result: 50.000066 | ||
+ | |||
+ | It's due to the rounding error that this does not return 8: | ||
+ | //echo -a $calc( $log(256) / $log(2) ) | ||
+ | </source> | ||
== Compatibility == | == Compatibility == |
Latest revision as of 14:20, 14 January 2018
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$log returns the natural logarithm (base e) of a number.
'e' is an irrational number whose digits begins with 2.718281828 'e' is the value where graphing the curve y=e^x has slope of X at every location along the curve. The natural logarithm of the value N is the exponent X where e^X is the value N. $log(e) is 1, $log(1) is 0, $log of values between 0 and 1 are negative. Returns error for N=0 or N=negative.
There may be a rounding error due to mIRC preserving fractional digits to only 6 places.
Synopsis[edit]
$log(N)
Paramters[edit]
NThe number you want the natural logarithm of
Properties[edit]
None
Example[edit]
//echo -a $log(50) result: 3.912023 //echo -a $calc(2.718281^3.912023) result: 49.99994
//var %e = 2.718281828 , %begin_balance = 10 , %interest_rate = .07 , %years = 20 | echo -a As compounding interval becomes shorter, ending balance approaches $ $+ $calc(%begin_balance * (%e ^(%interest_rate * %years))) You can use $log to find the base-X logarithm for any value N with $calc( $log(N) / $log(X) ) //echo -a base-3 logrithm of 50 is $calc( $log(50) / $log(3) ) result: base-3 logrithm of 50 is 3.560878 //echo -a $calc( 3 ^ 3.560878 ) result: 50.000066 It's due to the rounding error that this does not return 8: //echo -a $calc( $log(256) / $log(2) )
Compatibility[edit]
Added: mIRC v5.3
Added on: 13 Dec 1997
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
See also[edit]
mIRC identifier list