Decimal Help

Discussion in 'Plugin Development' started by zakarls, Jun 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    zakarls

    Im having trouble making decimals. No matter what decimal it is, it always rounds to a whole number. I currently use double to make the variable for the decimal. Is that wrong? Please help. Thanks :)
     
  2. Offline

    techboy291

    Can you post an example of how you create the double variables?
     
  3. Offline

    Tzeentchful

    zakarls
    Can you post the code you are having issues with.
     
  4. Offline

    zakarls

    techboy291 and Tzeentchful
    Code:
    int kills = getConfig().getInt(tplayer.getName() + ".kills");
                    int deaths = getConfig().getInt(tplayer.getName() + ".deaths");
                    double ratio = kills/deaths;
    My kills is 178 and deaths are 68 yet it returns ratio as 2.0
     
  5. Offline

    xTigerRebornx

    zakarls You get the both the values as ints (and store them as ints from what I can tell), get/set them as doubles
     
  6. Offline

    zakarls

    xTigerRebornx

    Ok. Ill try that

    zakarls
    Works. Thanks a lot

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page