Trying to store a decimal between 0&1 after dividing by 100
Hi, I'm not totally new to Java, been playing for a while but I've hit an embarassing brick wall. The answer to this must be simple but I just can't get it!!!
Basically I'm playing with making a little text based game. Each enemy has an amount of damage it can do, and I'm trying to make it relate to it's health.
ie a damage of 10 and 100 health returns 10
but a damage of 10 and 50 health returns 5.
I've tried to divide the health by 100 to get a decimal value then multiply by the damage to lower it sufficiently but for some reason Java stores a value of 0 when I do the divide by 100. Here's some code i quickly tested to check I wasn't going mad (the real game has loads of methods that would need explaining to get the values):
System.out.println(groups.jake.getHealth()); //correctly outputs value 50
double healthTest = groups.jake.getHealth()/100; //should store 0.5
System.out.println(healthTest); //outputs 0.0 instead of 0.5
What's going on?