Results 1 to 2 of 2
- 02-23-2013, 11:07 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 5
- Rep Power
- 0
Math.atan(double a) is not accurate.
EDIT!!!!
Silly me, I forgot that 5's and 10's were int. PLEASE DISREGARD for I FOUND OUT!
double in = 5/5;
double degrees = Math.toDegrees(Math.atan(in));
double in = 10/5;
double degrees = Math.toDegrees(Math.atan(in));
All numbers for "in" between 1 and 2 generated the exact same 45 degrees.
Without the Math.toDegrees(), it still generates .7xxxxxx (radian version :P);
My question is, why? I really don't see anything wrong, but this is the first time I use atan (normally I'd use sines and cosines);
halp.
-
Re: Math.atan(double a) is not accurate.
Run this program to see what is wrong:
Java Code:public class Foo { public static void main(String[] args) { double in = 5/5; System.out.println("in: " + in); in = 10 / 5; System.out.println("in: " + in); // so far so good, right? in = 3 / 5; System.out.println("in: " + in); // now the output is not so good. // what about... in = 3.0 / 5; System.out.println("in: " + in); // ah, that's better! } }
Similar Threads
-
more accurate average of array data
By jwl in forum New To JavaReplies: 2Last Post: 10-28-2012, 11:14 PM -
Math.atan --- To Degrees Help
By GregoryNeal in forum New To JavaReplies: 1Last Post: 03-07-2012, 07:54 AM -
Stimulsoft Reports.Fx. Convenient, Fast, Accurate.
By Andrew1000 in forum Java SoftwareReplies: 0Last Post: 09-20-2011, 01:12 PM -
keep double accurate to two decimal places
By africanhacker in forum New To JavaReplies: 5Last Post: 03-24-2011, 07:23 PM -
is Math.pow only used with type double?
By AprilFlowers in forum New To JavaReplies: 9Last Post: 10-23-2009, 05:38 AM
Bookmarks