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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:14:36+00:00 2026-06-12T09:14:36+00:00

My code passes an angle in radians to the cos , tan and sin

  • 0

My code passes an angle in radians to the cos, tan and sin. Everything seems to work fine except tan of 90, which gives the value 16331239353195370 for some odd reason. Example code:

import java.text.DecimalFormat;

public class mathtable {

  public static void main(String[] args) {

    System.out.println("Angle   Sin Cos Tan");
    System.out.println("-----   --- --- ---");

    for (double angle = 0.0; angle < 180; angle +=5) {
      double angle_rad = Math.toRadians(angle);
      double sin = Math.sin(angle_rad);
      String sin_4 = new DecimalFormat("#.####").format(sin);
      double cos = Math.cos(angle_rad);
      String cos_4 = new DecimalFormat("#.####").format(cos);
      double tan = Math.tan(angle_rad);
      String tan_4 = new DecimalFormat("#.####").format(tan);
      System.out.println(angle + "  " + sin_4 + "   " + cos_4 + "   " + tan_4);
    }
  }
}

Why is the value returned not strictly equal to IEEE infinity?

  • 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-12T09:14:36+00:00Added an answer on June 12, 2026 at 9:14 am

    Well, tan(pi/2) in radians is essentially infinite, isn’t it? So you’d expect to get a very large number, wouldn’t you? (It’s not infinity because pi/2 can’t be exactly represented as a double. You’re finding a value on an asymptotic curve very close to where it would become infinite.)

    See these graphs of sin/cos/tan to see what I mean, remembering that pi/2 radians is 90 degrees.

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

Sidebar

Related Questions

I have written some code which passes values between java and c using jni.
This code intermittently works. It's running on a small microcontroller. It will work fine
I have a test of C++ code that in most runs passes, but in
I am trying to repeat a code execution after predefined time passes and i
I have some code that converts variadic parameters into a va_list , then passes
I have this code which is passed to Paypal checkout: <?php foreach ($paypalBasket as
i have this code that passes the core data context to one of the
How would you fix the following bad code that passes too many parameters around?
JQuery code: //This passes NULL for CategoryID, CategoryName, ProductID, ProductName $(#btnPost).click(function () { var
The following (simplified version of our) code passes our JUnit tests under Hibernate, but

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.