math « Development « Java Data Type Q&A





1. Strange floating-point behaviour in a Java program    stackoverflow.com

In my program I have one array with 25 double values 0.04 When I try to sum these values in a loop I get following results:

0.0 + 0.04 = 0.04
0.04 + 0.04 ...

2. Is java.lang.Math.PI equal to GCC's M_PI?    stackoverflow.com

I am coding several reference algorithms in both Java and C/C++. Some of these algorithms use π. I would like for the two implementations of each algorithm to produce identical results, ...

3. How do I compare two longs as unsigned in Java?    stackoverflow.com

I'm storing bit patterns of unsigned 64-bit numbers in a long variable and want to calculate the distance between two of them on the unsigned range. Because Java interprets long as ...

4. Is there a Java equivalent of frexp?    stackoverflow.com

Is there a Java equivalent of the C / C++ function called frexp? If you aren't familiar, frexp is defined by Wikipedia to "break floating-point number ...

5. Why does this subtraction not equal zero?    stackoverflow.com

I happened upon these values in my ColdFusion code but the Google calculator seems to have the same "bug" where the difference is non-zero. 416582.2850 - 411476.8100 - 5105.475 = -2.36468622461E-011

6. Saturated addition of two signed Java 'long' values    stackoverflow.com

How can one add two long values in Java so that if the result overflows then it is clamped to the range Long.MIN_VALUE..Long.MAX_VALUE? For adding ints one can perform the arithmetic in ...

7. Efficient way to manipulate large powers of two    stackoverflow.com

The most efficient way to code powers of two is by bit shifting of integers. 1 << n gives me 2^n However, if I have a number that is larger than the largest ...

8. What is the right data type for calculations in Java    stackoverflow.com

Should we use double or BigDecimal for calculations in Java? How much is the overhead in terms of performance for BigDecimal as compared to double?

9. question about complex values in java    stackoverflow.com

We know that the general form of complex numbers is like this: z=a+i*b, where i is sqrt(-1). I have a question about how to express this in Java ?





10. java evaluate string to math expression    stackoverflow.com

I am trying to write a java routine where i can evaluate simple math expression from String for example: "5+3" or "10-40" or "10*3" i want to avoid a lot of if then ...

11. noob: Why divide always produces 0.0 float/integer problem?    stackoverflow.com

So if I have a range of numbers '0 - 1024' and I want to bring them into '0 - 255', the maths would dictate to divide the input by the ...

12. java arithmetic    stackoverflow.com

why this code returns wrong value?

int i=Integer.MAX_VALUE+1;
long l=Integer.MAX_VALUE+1;
System.out.println(l);
System.out.println(i);

13. Find null points of sinus function    stackoverflow.com

I want to implement a function in java that finds the null points of the sinus function. I know how to do that but I do not really understand the following ...

14. Java float/int implicit conversion    stackoverflow.com

I'm doing multiplication and division of floats and ints and I forget the implicit conversion rules (and the words in the question seem too vague to google more quickly than asking ...

15. Performing math operation when operator is stored in a string    stackoverflow.com

I have 2 integers:

int first= 10;
int second = 20;
and a string representing the operation (one of +, -, /, or *):
String op = "+";
How can I get the result of 10 ...

16. How accurate/precise is java.lang.Math.pow(x, n) for large n?    stackoverflow.com

I would like to calculate (1.0-p)^n where p is a double between 0 and 1 (often very close to 0) and n is a positive integer that might be on the ...





17. How to convert string to math equation?    stackoverflow.com

Possible Duplicate:
Java: Parse a mathematical expression given as a string and return a number
Hello there, I would like to ask you, if exist some way ...

18. What's difference between Math.pow(9, 18) and 9^18    stackoverflow.com

when I use Math.pow(9, 18) =150094635296999136 when I use web Calculator 9^18 = 150094635296999121 (http://web2.0calc.com/) when I use goggle calculator 9^18 = 1.50094635 × 10^17 why it is different ?

19. Doubt about strictfp and StrictMath    stackoverflow.com

I have a little technical question, is it the same to call:

   public static strictfp double myMethod(double phi){
       return Math.exp(phi);
   }
or: ...

20. Can 0.99999999999 be rounded to 1.0 when multiplying?    stackoverflow.com

When multiplying a floating number that is very close to 1 with an int > 0, can it ever be interpreted as 1. That is, if Math.random() returns its highest possible ...

21. String in Java Arithmetic (evaluating mixed type expression)    stackoverflow.com

How would I answer a question such as "what does the below expression evaluate to".

"2 + 2 " + 3 + 4; 
because I'm having a really hard time on the ...

22. String maths    coderanch.com

24. Convert A String To Math Problem    java-forums.org

If you cannot use Javascript, what you need to do is convert your infix (2 + 3) expression into a postfix (2 3 +) expression. Then you can evaluate the expression using a Stack. For each operand (number) push onto Stack. For each operator (+-*/etc) pop off 2 values from the Stack, perform operation, push result back onto Stack. Once you ...

25. Java math and datatype    forums.oracle.com

26. Doing math with strings    forums.oracle.com

I'm helping a friend with an assignment to make a simple encryption/decryption program. We have pretty much everything working except the encrypting and decrypting parts. According to the assignment, she's supposed to encrypt by adding 1 to the ascii/unicode value of each letter, and then decode by doing the reverse. Unfortunately, Java is not my forte, and I can't for the ...

27. String to Math function    forums.oracle.com

Hi, I am new to this forum so I don't know if this is the right place for his topic, if it is not please forgive me...thanks Ant0nisS Now let's get in to the point... I wanted to know if there any way to take a string(e.g. 2+5*(9+2*7/5))-sin(4/(2*(tan(60)))) and convert it into a math function to give me the result...please help ...

28. Help Please! How do i Convert a string to math operator?    forums.oracle.com

Hi. I am trying to write a calculator that takes a string from the user and calculates the expression. For example, 55 * 4 + ( 55 - 30 ) + 7 I can use the string tokenizer and seperate the string into individual parts, then use parsedouble for the numbers, but is there a way to parse the operators? i ...

29. Data types and some simple maths    forums.oracle.com

30. Evaluate String math expression    forums.oracle.com