Apply Modulus Operator to Floating Point Values in Java



To apply modulus (%) operator to floating-point values in an effortless task. Let us see how.

We have the following two values −

double one = 9.7;
double two = 1.2;

Let us now apply the modulus operator −

one % two

The following is the complete example that displays the output as well −

Example

 Live Demo

public class Demo {
   public static void main(String args[]) {
      double one = 9.7;
      double two = 1.2;
      System.out.println( one % two );
   }
}

Output

0.09999999999999964
Updated on: 2019-07-30T22:30:24+05:30

722 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements