Solved Math

Discussion in 'Spigot Plugin Development' started by MadMaxCookie, May 22, 2016.

  1. Did java prefer with PEMDAS ?

    example int i = 2 - 7 * 7 + 2;

    i will return to 49 ?

    or it will return to -33 ?
     
  2. This returns -45, btw. But it does follow PEMDAS
    (2 - (7 * 7) + 2 = 2 - 49 + 2 = 45)
     
  3. thanks for the help buddy another question

    what would be the value if this happened somehow.
    int i = lower / higher
    something like i = 2/5;

    do I have to check if the dividend is greater than divisor always when using it an java for (int i = value / value ;
     
    • Like Like x 1
  4. @MadMaxCookie It always rounds downwards, so 2/5 would return 0. If the value was a double, you would get 0.4. 4/5, for example, would also return 0
     
  5. oh my bad thanks for information now I have to check if the divident is always higher than divisor what a relief thanks for help buddy you saved my butt :D.
     
  6. i will be 0 since ints can't handle decimal numbers, use double for that
     
  7. hmm I'm not asking how to return i with decimals. I'm asking certain things which is being solved already don't repeat myself

    check the prefix above bud.