# Solved Kill death/ratio not showing correctly, double not working?

Discussion in 'Spigot Plugin Development' started by mrdado243, Apr 21, 2017.

So i'm making kill/death ratio on my server that is displayed by scoreboard but for some reason it's not working correctly it's not showing decimal value!
i will upload screenshots of problem thanks for help!
This is how it looks

this is how it should be (google says so, .. lel)

this is convertion

• Agree x 1
2. ### Bancey

This is because you're still just dividing integers, using
Code (Text):
Double.valueOf(yourIntHere)
should do the trick.

• Like x 1

uhm please check the code i need to get kill/death ratio and ints are full numbers so?

• Like x 1
4. ### Bancey

Yeah... So convert them to a type that can represent decimals, the snippet I posted above will help you do this.

• Agree x 1
5. ### dNiym

When you write it to the scoreboard, what does that line look like?

Do a system.out right after you assign kdr to its variable and see what it outputs to the console.

Sent from my iPhone using Tapatalk

it is getting values from config every 60 ticks while scoreboard updates.

• Like x 1

ok, .. so i should make int that devides 2 ints and than this double?

• Like x 1
8. ### Bancey

Integers represent a whole number, therefore doing an integer division will result in a whole number. Hence why you are getting 2.0 because the result has been rounded. In order to get a decimal result you need to use types that can represent decimals.

Code (Text):
int kills = getConfig().getInt("playerkills." + p.getName().toLowerCase());
int deaths = getConfig().getInt("playerdeaths." + p.getName().toLowerCase());
double kda = Double.valueOf(kills) / Double.valueOf(deaths);
The above should work.

• Winner x 1