Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1104927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:33:08+00:00 2026-05-17T01:33:08+00:00

All math functions in JavaScript use radians in place of degrees. Yet they are

  • 0

All math functions in JavaScript use radians in place of degrees.
Yet they are either unequal, or I am way off base.

The conversion from degrees to a radian is:

var rad = angle * Math.PI / 180

A 90 degree angle equals 1.57079633 radian

The cosine of a 90 degree angle equals 0.
The cosine of a 1.57079633 radian equals -3.20510345 × 10-9.

Note that in the Javascript, everything is done in one step to avoid rounding errors:

var cos = Math.cos(angle * Math.PI / 180);

I am obviously missing something obvious here, but boy is it screwing up the code.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:33:08+00:00Added an answer on May 17, 2026 at 1:33 am

    everything is done in one step to avoid rounding errors

    How does that avoid rounding errors? It just means that the rounding errors aren’t available in a separate variable, that’s all.

    The true value of pi can’t be accurately represented as a floating point number, so the true value of pi / 2 can’t either. So you can’t give Math.cos the exact value needed to get 0. But hey – 10-9 is a very, very small number. It means that if you were drawing a line 10,000 kilometres long, you’d end up veering 1cm away from the relevant axis.

    This is exactly the kind of thing you should expect when dealing with floating point numbers. Don’t compare with equality – compare within some tolerance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While I understand the Math.round/ceil/floor functions in javascript, I have been unable to come
We all hear that math at least helps a little bit with programming. My
I am totally new to math/numerical analysis programming and I was looking all over
Hey all. I'm computing the angle between two vectors, and sometimes Math.Acos() returns NaN
I wrote an abstraction class for a math object, and defined all of the
I'm going to build a simple math graph for a browser application. Therefore all
This question regards my personal photography website. I use the following javascript to generate
What I want to do is use the JS functions for additional input fields
i want to pick highest value from an array so i use math.max function
I need a JavaScript function that goes through all of the elements of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.