# Hey its me again

• 03-11-2011, 12:28 AM
Phyxed
Hey its me again
I know this will probably be such an easy thing but I cant figure out how to change my 9/blop to give me a 2.5. I keep getting an error. Im under the assumption that casting a double on either the 9 or the blop will give me a result with a 2.5 but i keep getting an error with the possible loss of percision. Any help would be appreciated, and here is the code thus far.

int blip = 5;
int blop;

blop = blip%3;
blip = 9/(double)blop;
System.out.println("Today " + blop + " cats");
System.out.println("caught " + blip + " mice.");

Thanks again guys,

Phyxed
• 03-11-2011, 12:34 AM
kwgivler
Did you try making blip a double instead of an int?
• 03-11-2011, 12:41 AM
Phyxed
I did and I got the same error at line 17 where its blop = blip%3. Is there anyway to force a double on the blip = 9/blop ?because what i have posted originally is giving me an error and its because of that double infront of blop.
• 03-11-2011, 12:50 AM
kwgivler
Quote:

Originally Posted by Phyxed
I did and I got the same error at line 17 where its blop = blip%3. Is there anyway to force a double on the blip = 9/blop ?because what i have posted originally is giving me an error and its because of that double infront of blop.

Well you could make blip and blop both doubles or use a cast like this:

Code:

`blop = (int) blip % 3;`
I think this is what you want:

Code:

```                double blip = 5;                 int blop;                 blop = (int) blip % 3;                 blip = (double) 9 / blop;                 System.out.println("Today " + blop + " cats");                 System.out.println("caught " + blip + " mice.");```
• 03-11-2011, 01:37 AM
sunde887
When you run into problems like this the best thing to do is experiment. If you think it's going to require a cast, try it. Try casting different to different types until you get it right. When you get it working correctly, take a minute and think about why it works that way and not the other ways.
• 03-13-2011, 08:34 PM
Phyxed
I appreciate the help a lot guys thank you very much!
• 03-13-2011, 10:22 PM
sunde887