Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Java MOD operation with the usage of BigDecimal

I have this method for calculating Mod:

    private static double calcMod(double yVal, int nVal) {
    return yVal % nVal;
}

Where

  • yVal = 2.5469420819186795316622496024263e+46
  • nVal = 187

when I calculate it with calculator the result equals 2, however, the returned value equals 97.0, can anyone explain how to use BigDecimal to get the expected result which is = 2.

Comments