← All stories
● Covered by 1 source · 1 reportLow impact1 neutral

Using 'Turns' Instead of Radians Simplifies Trigonometric Calculations in Code

🔄 Updated 2h ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • Many codebases convert values to radians for trig functions.
  • Trigonometric libraries often convert radians back internally.
  • This creates redundant multiplication and division by pi.
  • Using 'turns' (0-1 range for a full circle) avoids these conversions.

The Problem with Radians in Code

Programmers frequently convert angular values to radians when calling trigonometric functions like `sin()` or `cos()`. This is a common practice, as radians are the standard unit for these mathematical functions. However, this often leads to redundant calculations within the software stack.

Redundant Conversions in Math Libraries

Many trigonometric function implementations, such as those found in AVX2 libraries, internally convert the radian input back to a different scale. For example, an input multiplied by `2 * pi` by the programmer might immediately be multiplied by `4 / pi` inside the `sin()` function, effectively canceling out the `pi` factor. This means the code is performing a conversion to radians only for the library to convert it back, creating an unnecessary computational step.

Introducing 'Turns' for Simplicity

The article proposes using 'turns' as a unit for angular measurement, where one turn represents a full circle (0 to 1). If a value `h` is already periodic on the range 0 to 1, directly passing it to a trigonometric function designed to accept 'turns' would eliminate the need for `pi` or `tau` multiplications. This would simplify the calling code and remove the redundant conversions performed by the underlying math libraries.

Impact on Code Efficiency and Readability

Adopting 'turns' could lead to slightly more efficient code by removing unnecessary arithmetic operations. More significantly, it could improve code readability by making the intent clearer when dealing with periodic values that naturally range from 0 to 1. This change, while minor, addresses an overlooked opportunity for optimization and clarity in common programming practices.

✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →

The daily brief

One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.

One email a day. Unsubscribe in one click, any time.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~28 min · 23 stories · Aug 19

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

A recent article suggests that using 'turns' (a unit where one turn equals a full circle) instead of radians can simplify trigonometric function calls in programming. This approach eliminates unnecessary conversions to and from radians, which are often performed internally by math libraries, leading to more efficient and readable code.