conv():

WE can convert any number from one mathematical base number system to another base number system by using conv() function in MySQL. Here is the syntax
conv(n,base_from, base_to);
Here n is any number and base_from is base of n ( the number ) at present. base_to is the base of the number we want to covert. Minimum base value is 2 and maximum base value is 36. Let us try one example
Select conv('b',16,2);
Here number is b of base 16 , after conversion it will have base of 2 . The output is here
1011
Now let us try one octal number

Octal number to decimal ( base 10 )

conv(11,8,10)
In above code number 11 is of base 8 and after conversion it became decimal number of base 10. Here is our output
9
In conventional way it is 11=1x81 + 1x80 , so 11 in octal is equal to 9 in decimal. You can also use MySQL oct function to covert decimal number to Octal system

Hex to binary

Hex numbers have base of 16 and binary is of base 2
select  conv('D',16,2)
Output is
1101

Decimal to Hex

Decimal is of base 10 and Hex is of base 16
select conv(10,10,16);
The output is here
A

Convert numbers from decimal to Octal base system

We can convert decimal number to octal number by using oct function. Here are examples
select oct(7); // output 7
select oct(8); // out put 10
select oct(9); // out put 11
select oct(10); // out put 12 

SQL Math References LOG10() LOG() ABS() to get Absolute value
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    SQL Video Tutorials










    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer