Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

floorMod()

Example

Provide the remainders resulting from divisions rounded down.

System.out.println(Math.floorMod(10, 4));
System.out.println(Math.floorMod(-10, 4));
System.out.println(Math.floorMod(10, 3));
System.out.println(Math.floorMod(-10, 3));

Definition and Usage

The floorMod() method computes the remainder of an integer division, where the quotient is rounded down.

The outcome equals to dividend – Math.floorDiv(dividend, divisor) * divisor.

Syntax

One of the following:

public static int floorMod(int dividend, int divisor )

public static long floorMod(long dividend, long divisor

Parameter Values

Parameter

Description

dividend

Needed: The number to be divided to find the remainder.

divisor

Needed: The number by which the dividend is divided to find the remainder.

Technical Details

Return:

An int or long value representing the remainder resulting from the division of two integers.

Throws:

ArithmeticException is thrown if the divisor is zero.

Java Version:

1.8+