Getting the remainder of a floating-point division

% returns the remainder of an integer division. If you want to know the remainder of a floating-point division, you can use the static method IEEEremainder of the Math class:

import java.math.*;
                           
public class Main 
{  
   public static void main(String args[]) throws Exception {
      System.out.println(Math.IEEEremainder(13.5, 3.0));
   }
}

outputs 1.5