![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_1646196931.webp)
Mathematical Functions
911
mysql>
SELECT LOG(2,65536);
-> 16
mysql>
SELECT LOG(10,100);
-> 2
mysql>
SELECT LOG(1,100);
-> NULL
LOG(B,X)
[910]
is equivalent to
LOG(X) / LOG(B)
[910]
.
•
LOG2(X)
[911]
Returns the base-2 logarithm of
X
.
mysql>
SELECT LOG2(65536);
-> 16
mysql>
SELECT LOG2(-100);
-> NULL
LOG2()
[911]
is useful for finding out how many bits a number requires for storage. This function is
equivalent to the expression
LOG(X) / LOG(2)
[910]
.
•
LOG10(X)
[911]
Returns the base-10 logarithm of
X
.
mysql>
SELECT LOG10(2);
-> 0.30102999566398
mysql>
SELECT LOG10(100);
-> 2
mysql>
SELECT LOG10(-100);
-> NULL
LOG10(X)
[911]
is equivalent to
LOG(10,X)
[910]
.
•
MOD(N,M)
[911]
,
N % M
[907]
,
N MOD M
[907]
Modulo operation. Returns the remainder of
N
divided by
M
.
mysql>
SELECT MOD(234, 10);
-> 4
mysql>
SELECT 253 % 7;
-> 1
mysql>
SELECT MOD(29,9);
-> 2
mysql>
SELECT 29 MOD 9;
-> 2
This function is safe to use with
BIGINT
values.
MOD()
[911]
also works on values that have a fractional part and returns the exact remainder after
division:
mysql>
SELECT MOD(34.5,3);
-> 1.5
MOD(N,0)
[911]
returns
NULL
.
•
PI()
[911]
Returns the value of
π
(pi). The default number of decimal places displayed is seven, but MySQL
uses the full double-precision value internally.
mysql>
SELECT PI();
-> 3.141593
mysql>
SELECT PI()+0.000000000000000000;
-> 3.141592653589793116
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...