What happens if the value of number ‘N’ in CONV() function is not as per accordance with its base?

MySQLMySQLi Database

MySQL returns 0 as output if the number given in CONV() function is not as per accordance with its base. Suppose, if we want to convert decimal number 9 into the 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 returns 0 as output.

Example

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

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

1 row in set (0.00 sec)

As we know that the values of octal number system must be between 0 to 7, hence the number system for number 9 must be decimal i.e. 10.

raja
Published on 20-Feb-2018 12:08:22
Advertisements