Degrees, Radians, and the Unit Programmers Always Forget to Convert
Why almost every programming language's math functions expect radians, and the specific bug pattern that results from forgetting.
Published May 15, 2026
Degrees are the intuitive, everyday unit for angles, a right angle is 90, a full circle is 360. Radians are the unit almost every programming language's math library actually expects, and mixing the two up is one of the most common, easy-to-miss bugs in anything involving rotation or trigonometry.
Why radians, not degrees, became the programming default
A radian is defined so that a full circle equals exactly 2π radians, which isn't an arbitrary convention, it's the unit that makes calculus and trigonometric derivatives come out clean, without extra conversion constants cluttering every formula. Because of that mathematical convenience, it became the standard unit in most math libraries, including JavaScript's Math.sin, Math.cos, and every other trig function.
The bug this causes in practice
Passing 90 (meaning 90 degrees) directly into Math.sin() doesn't throw an error, it silently computes the sine of 90 radians instead, a completely different, nonsensical angle in this context. The code runs, returns a number, and that number is simply wrong, which is exactly the kind of bug that's hard to catch because nothing crashes.
The fix is one line, remembering to write it is the hard part
Multiplying degrees by π/180 converts to radians; multiplying radians by 180/π converts back. The math is trivial. The actual discipline is building the habit of checking, every time an angle crosses into a math function, whether it's already in the unit that function expects, rather than assuming.