Official javadoc says that Math.floor returns a double that is "equal to a mathematical integer", but then why shouldn't it return an int?
|
I am looking for square root functions (to use in java) that can give square roots upto atleast to 5-6 decimal places accurately. If there is a way to control accuracy ... |
Forgive me if this is a dumb beginners problem, but I really don't get it.
I have a member variable declared like so:
public Double Value;
When I assign 3.14159265 to Value and try ... |
How to I write a function that approximates a double in the following manner, returning an int:
function (2.3) -> 2
function (2.7) -> 3
function (-1.2) -> -1
function (-1.7) -> -2
|
I am using the Apache Commons math.Fraction class to convert my doubles to fractions, which is working fine.
However, I need it to calculate these fractions in a way that ... |
I need to implement the harvesine distance in my java code.
I found this snippet in Javascript, and I need to convert it to java.
- How can I convert latitude and longitude to ...
|
how can I make this expression not end up being a zero.
double dBaseFitness = (double) baseFitness;
...
|
|
I am currently writing a calculator program in java. It is my first java program, I am used to c++.
I have noticed that doubles in java are not at all like ... |
This is how I am creating q
Double q = ((r * (i/5)) + y);
at this point the values of the other variables are
r = 3.470694142992069E-5
i = 1
y = -116.30237535361584
but
q = ...
|
I could translate the code to use BigDecimal or the Apfloat library rather than double but that would take considerable effort. I was hoping that there was an FOSS library that ... |
Why is only the last number wrong in the output this code:
public class Test {
public static void main(String[] args) {
...
|
I'm doing a bit of modding to a popular game(Minecraft) and I seen these lines in the terrain generation
double d4 = 1.0D;
d4 *= d4;
d4 *= d4;
d4 = 1.0D - d4;
double ...
|
This one threw me for a loop for a bit. When I call Math.ceil(5.2) the return is the double 6.0. My natural inclination was to think that Math.ceil(double a) would return ... |
Is there a good reason Math.floor() and Math.ceil() return double's instead of int (or more precisely long)? Is this just a matter of "it was done in JDK 1.0 this way and we can't change it" or is there some justification to it? I haven't seen a better explanation other than "it's what the API documentation says", which doesn't really answer ... |
I'm trying to calculate compound interest only using integers and I keep getting errors messages associated with this formula: amount = principal * Math.pow( 1.0 + rate, year ); I get stuff like: InterestTwo.java:20: pow(double,double) in java.lang.Math cannot be applied to (int) or InterestTwo.java:20: possible loss of precision found : double required: int amount = principal * Math.pow( 1.0 + rate, ... |
First off, many here don't take too well to folks who post the entire assignment, without showing any work as many will assume that the poster wants someone else to do the assignment for them. I will assume that this isn't you, that you don't want someone to do it all for you. Secondly, our track record for helping folks who ... |
|