Home  >  Article  >  Database  >  What happens if the value of the number "N" in the CONV() function does not match its base?

What happens if the value of the number "N" in the CONV() function does not match its base?

PHPz
PHPzforward
2023-08-27 14:29:101055browse

如果 CONV() 函数中数字“N”的值与其基数不符会发生什么?

If the number given in the CONV() function does not match its base, MySQL will return 0 as output. Suppose, if we want to convert the decimal number 9 to a number in binary number system, then in this case the value of from_base must be 10, but if we provide 8 as the value of from_base, then MySQL will return 0 as output.

Example
mysql> Select CONV(9,8,2);

+-------------+
| CONV(9,8,2) |
+-------------+
| 0           |
+-------------+

1 row in set (0.00 sec)

We know that octal values ​​must be between 0 and 7, so the number system for the number 9 must be decimal, which is 10.

The above is the detailed content of What happens if the value of the number "N" in the CONV() function does not match its base?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete