PLSQL | REMAINDER Function

The REMAINDER function is an inbuilt function in PLSQL which is used to return the remainder of a divided by b.

Syntax:

REMAINDER(a, b)

Parameters Used:
This function accepts two parameters a and b which is used in calculating the remainder when a is divided by b.



Return Value:
This function returns a numeric value when the input number a is divided by b.

Supported Versions of Oracle/PLSQL is given below:

  1. Oracle 12c
  2. Oracle 11g
  3. Oracle 10g
  4. Oracle 9i
  5. Oracle 8i

Let’s see some examples which illustrate the REMAINDER function:

Example-1:

DECLARE 
   Test_Number number1 := 15;
   Test_Number number2 := 5;
   
BEGIN 
   dbms_output.put_line(REMAINDER(Test_Number number1, 
                                  Test_Number number2)); 
   
END; 

Output:

0

In the above example, when 15 is divided by 5 then it returns a remainder of 0.

Example-2:

DECLARE 
   Test_Number number1 := 11.6;
   Test_Number number2 := 2;
   
BEGIN 
   dbms_output.put_line(REMAINDER(Test_Number number1, 
                                  Test_Number number2)); 
   
END; 

Output:

-0.4

In the above example, when 11.6 is divided by 2 then it returns a remainder of -0.4

Example-3:

DECLARE 
   Test_Number number1 := -15;
   Test_Number number2 := 4;
   
BEGIN 
   dbms_output.put_line(REMAINDER(Test_Number number1, 
                                  Test_Number number2)); 
   
END; 

Output:

1

In the above example, when -15 is divided by 4 then it returns a remainder of 1.

Advantage:
This function is used to find out the remainder when a is divided by b.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.