PI() function: π

SELECT PI()
Output is 3.141593

This is a mathematical constant (π) and the value displayed by MySQL is for 7 digits after decimal but internaly stores double-precision value of PI.

PI() with DEGREES()

DEGREES function converts radian to degree.
SELECT DEGREES(PI()); // Output is 180
SELECT DEGREES(PI()/2); // Output is 90
SELECT DEGREES(PI()/3); // Output is 59.99999 

PI with SIN() COS()

We can get sine of any value in radians by using sin(), note that sin(x) takes input in redian. Value of x is in redian.
SELECT SIN(PI()); // Output is 1.2246467991473532e-16
We can use use ROUND Function to rounds to output
SELECT ROUND(SIN(PI())); // Output is 0 
SELECT ROUND(SIN(PI()/2)); // Output is 1
We will allow some decimal places to be shown as the value of SIN varies between 0 and 1.
SELECT ROUND( SIN( PI( ) /3 ), 3 ) //Output is 0.866 
SELECT ROUND( SIN( PI( ) /4 ) , 4 ) // Output is 0.7071 
 
We can try COS values
SELECT ROUND( COS( PI( ) /3 ), 3 ) //Output is  0.500
SELECT ROUND( COS( PI( ) /2 ), 3 ) // Output is 0.000
 


SQL Math References COS() SIN() function DEGREES() to convert redian to degee
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com

    Post your comments , suggestion , error , requirements etc here





    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