Dividing little too accurate

Discussion in 'Plugin Development' started by Mrcool234, Apr 20, 2014.

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

    Mrcool234

  2. Offline

    xTrollxDudex

    Mrcool234
    Don't use float or double if you want accuracy. Use BigDecimal or long and int.
     
  3. Offline

    Mrcool234

    xTrollxDudex
    Well it's a KDR plugin so i need doubles or decimals
     
  4. Offline

    Dpasi314

    You could think about just formatting your decimal, to the appropriate number of digits after the decimal point. Albeit the actual number will still be like that, however, it will be displayed to whatever you set the formatting to.

    Code:
    DecimalFormat decimalFormat = new DecimalFormat("#.##");
    decimalFormat.format(yourDoubleHere);
    
    So your number would be 0.16 if you had the formatting like this.
     
  5. Offline

    Mrcool234

    @Dpasi
    Nope still broken
     
  6. Offline

    Dpasi314

    You actually have to output your number with the decimalFormat.format(double a);
    Basically the number you're outputting now, just needs to be outputted with the decimalFormat.format thing.

    Code:
    BEFORE:
    System.out.println(double);
     
    AFTER:
    System.out.println(decimalFormat.format(double));
    
     
  7. Offline

    Mrcool234

    Last edited by a moderator: Jun 7, 2016
  8. Offline

    oscarshi1995

    Player.SetPrefix(<KDR STRING HERE> + Player.getPrefix());
     
  9. Offline

    Mrcool234

    oscarshi1995
    It didn't work and it does come up.

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  10. Offline

    AoH_Ruthless

    Mrcool234
    Don't bump more than once every 24 hours. Instead of saying it doesn't work, paste your code to help us help you..
     
Thread Status:
Not open for further replies.

Share This Page