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 9092899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:57:10+00:00 2026-06-16T22:57:10+00:00

Shouldn’t the following statement hold? assertTrue(Double.isNaN(Math.tan(Math.acos(0d)))); But instead of Double.NaN Java returns 6.123233995736766 *

  • 0

Shouldn’t the following statement hold?

assertTrue(Double.isNaN(Math.tan(Math.acos(0d))));

But instead of Double.NaN Java returns

6.123233995736766 * 10^-17    

on my 64-bit box.

EDIT:
This was a Copy and Paste error. In fact Java returns 1.633123935319537E16

I’m aware that this is because of the floating point representation, but i was under the impression that those undefined values of the tangent function would get the same treatment as e.g. Math.sqrt(-1d) but I guess in this case java.lang.Math just checks if the argument is positive before evaluating.

  • 1 1 Answer
  • 0 Views
  • 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-06-16T22:57:11+00:00Added an answer on June 16, 2026 at 10:57 pm

    I get something different.

    System.out.println(Math.tan(Math.acos(0d)));
    // and the tan for the next representable value.
    System.out.println(Math.tan(Math.acos(0d) + Math.ulp(Math.acos(0d))));
    

    prints

    1.633123935319537E16
    -6.218431163823738E15
    

    A 64-bit floating point cannot represent PI/2 exactly (it has an infinite number of digits) it represents a number close to this value and the tan() of this value is finite.

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

Sidebar

Related Questions

Shouldn't the compiler automatically cast to a double in the following? At least according
Hopefully this shouldn't be too complicated....but I have the following character string in x
I know this shouldn't be that hard, but I couldn't find the answer on
I know I shouldn't use C-style arrays but I was trying to look for
I feel like I shouldn't be asking such a simple question but I can't
I know I shouldn't be outputting things directly in PHP, but using a template
Any reason why c shouldn't equal 0.321? >>> from math import ceil >>> a
I know I shouldn't be exposing a List<T> in a property, but I wonder
I understand Object.prototype shouldn't be altered, but out of curiosity, what are all of
I strongly suspect I shouldn't be using a static factory method here, but for

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.