rad()
Published Oct 18, 2023
Contribute to Docs
The rad()
function in Lua’s math library converts a number given in degrees to its equivalent in radians.
Syntax
math.rad(degree)
degree
: The number in degrees.
Example
In this example, math.rad()
converts 180 degrees to radians.
local x = 180local answer = math.rad(x)local output = string.format("%.0f in radians is %.4f", x, answer)print(output)
This will result in the following output below.
180 in radians is 3.1416
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Lua on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Lua
Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.Beginner Friendly4 hours