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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:42:49+00:00 2026-05-30T06:42:49+00:00

Is the java Math.atan() function known to have any issues? I’m using it in

  • 0

Is the java Math.atan() function known to have any issues? I’m using it in my code and for some bizarre reason that I can’t work out, the function will return 0 for 45 degrees of motion, jumps to 45 and stays at 45 until it reaches 63.4 degrees where it starts mapping properly until it reaches -63.4 degrees and the problem repeats. I’m so confused! I’ve triple checked that my input is always correct but yet the problem recurs!

Here’s my code

int adjacent = p2.x - p1.x;
if (adjacent == 0) adjacent = 1; //Prevent division by 0
int opposite = p2.y - p1.y;
double pheta = Math.atan(opposite/adjacent);
System.out.println(opposite + "/" + adjacent + ", pheta=" + Math.toDegrees(pheta));

Here’s some printouts on test data

73/102, angle=0.0
73/101, angle=0.0
74/100, angle=0.0
74/99, angle=0.0
75/99, angle=0.0
76/97, angle=0.0
76/96, angle=0.0
77/95, angle=0.0
78/95, angle=0.0
78/94, angle=0.0
79/92, angle=0.0
80/91, angle=0.0
81/90, angle=0.0
81/89, angle=0.0
82/87, angle=0.0
83/86, angle=0.0
84/85, angle=0.0
84/84, angle=45.0
84/83, angle=45.0
85/83, angle=45.0
85/82, angle=45.0
85/81, angle=45.0
85/80, angle=45.0
86/79, angle=45.0
87/78, angle=45.0
87/77, angle=45.0
87/76, angle=45.0
88/75, angle=45.0
88/74, angle=45.0
88/73, angle=45.0
89/72, angle=45.0
90/70, angle=45.0
90/69, angle=45.0
91/68, angle=45.0
92/67, angle=45.0
92/66, angle=45.0
93/65, angle=45.0
93/64, angle=45.0
93/62, angle=45.0
94/62, angle=45.0
94/61, angle=45.0
95/61, angle=45.0
95/60, angle=45.0
95/59, angle=45.0
95/57, angle=45.0
95/56, angle=45.0
96/55, angle=45.0
96/54, angle=45.0
96/53, angle=45.0
97/53, angle=45.0
97/52, angle=45.0
97/51, angle=45.0
98/51, angle=45.0
98/50, angle=45.0
98/49, angle=63.43494882292201
98/47, angle=63.43494882292201
99/45, angle=63.43494882292201
99/42, angle=63.43494882292201
100/40, angle=63.43494882292201
100/38, angle=63.43494882292201
100/36, angle=63.43494882292201
100/34, angle=63.43494882292201
100/33, angle=71.56505117707799
101/33, angle=71.56505117707799
101/32, angle=71.56505117707799
101/31, angle=71.56505117707799
101/30, angle=71.56505117707799
102/29, angle=71.56505117707799
102/28, angle=71.56505117707799
102/27, angle=71.56505117707799
103/27, angle=71.56505117707799
103/25, angle=75.96375653207353
103/24, angle=75.96375653207353
103/23, angle=75.96375653207353
103/22, angle=75.96375653207353
104/21, angle=75.96375653207353
104/19, angle=78.69006752597979
105/18, angle=78.69006752597979
105/16, angle=80.53767779197439
106/15, angle=81.86989764584403
106/14, angle=81.86989764584403
106/13, angle=82.87498365109819
106/12, angle=82.87498365109819
106/11, angle=83.6598082540901
106/10, angle=84.28940686250037
106/9, angle=84.8055710922652
107/8, angle=85.60129464500447
108/6, angle=86.82016988013577

Any ideas?

  • 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-05-30T06:42:51+00:00Added an answer on May 30, 2026 at 6:42 am

    You perform integer division, which results in round numbers, try:

    Math.atan((double)opposite/adjacent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the opposite of the Math.tan(double x) function of java? I know that
I am writing a Java code generator. I have an immutable Map that contains
I want to have a fast log1p function for Java. Java has Math.log1p, but
I was looking over this code to calculate math.sqrt in Java. Why did they
Java Newbie here. I have a JFrame that I added to my netbeans project,
BigDecimal is a class in the java.math package that has a lot of benefits
I have connected Java program to Oracle database using JDBC. I want to store
I noticed that people prefer importing javax.swing.JFrame instead of javax.swing.* , importing java.math.BigInteger instead
I have a problem import java.math.BigInteger; import java.io.*; import java.util.*; import java.lang.*; public class
I did some testing with C++ hypot() and Java Math.hypot . They both seem

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.