Results 1 to 3 of 3
Thread: Math in java
- 11-22-2010, 02:57 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 26
- Rep Power
- 0
Math in java
[I]Array[i].fee = ((Array.num / ((((double)number2 / 100) + 1)))) * (((double)number1 / 100) + 1);
Isn't coming out the way I want it to...
number2 = 10
number1 = 15
number2 and number1 are both int values, but I thought the typecasts I used would have helped.
(((double)number2 / 100) + 1))) is coming out 1.0 when it should be 1.1
(double)number1 / 100) + 1) is coming out as 1.1 when it should be 1.15
Maybe I've done something wrong but I can't pick it, been sitting for an hour at this code.Last edited by blug; 11-22-2010 at 02:59 PM.
- 11-22-2010, 03:00 PM #2
Print the steps out separately instead of waiting until the whole expression is evaluated to see what's going on.
Hint: what is being cast as a double in each of the following?
Java Code:(double) number2 / 100
Java Code:(double) (number2 / 100)
Java Code:((double) number2) / 100
- 11-22-2010, 03:21 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 26
- Rep Power
- 0
Similar Threads
-
Help with java math
By gabrielfirestorm in forum New To JavaReplies: 6Last Post: 10-25-2010, 02:54 PM -
Help need on math java program
By zidangus in forum New To JavaReplies: 27Last Post: 07-07-2010, 03:48 AM -
Java Math
By levent in forum Java TutorialReplies: 1Last Post: 05-12-2008, 10:03 AM -
java.lang.Math
By eva in forum New To JavaReplies: 2Last Post: 01-31-2008, 05:17 PM -
Help with math in java
By fernando in forum New To JavaReplies: 1Last Post: 08-06-2007, 07:05 AM
Bookmarks