  # Python | Decimal remainder_near () method Decimal # remainder_near (): remainder_near () — it is a method of the Decimal class that returns x — y * n, where n — integer closest to the exact x / y value

Syntax: Decimal.remainder_near ()

Parameter: Decimal values ​​

Return: x - y * n, where n is the integer nearest the exact value of x / y

Code # 1: Example for `remainder_near()`

` `

` # Python program explaining # remainder_near () method   # decimal library load from decimal import *     # Initialize decimal value a = Decimal ( - 1 )   b = Decimal ( ` 0.142857` )   # print decimal values ​​ print ( "Decimal value a:" , a) print ( " Decimal value b: " , b)     # Using the Decimal.remainder_near ( ) print ( " Decimal a with remainder_near () method: " , a.remainder_near (b))   print ( "Decimal b with remainder_near () method:" , b.remainder_near (b)) `

Output:

` Decimal value a: -1 Decimal value b: 0.142857 Decimal a with remainder_near () method: -0.000001 Decimal b with remainder_near () method: 0.000000 `

Code no. 2: Example for `remainder_near()`

` `

` # Python program explaining # remainder_near () method   # decimal library loading from decimal import *      # Initialize decimal value a = Decimal ( `-3.14` )    b = Decimal ( `321e + 5` )     # print decimal values ​​ print ( "Decimal value a: " , a) print ( "Decimal value b:" , b)     # Using the Decimal.remainder_near () method print ( "Decimal a with remainder_near ( ) method: " , a.remainder_near (b))    print ( "Decimal b with remainder_near () method:" , b.remainder_near (b)) `

` `

Output:

` Decimal value a: -3.14 Decimal value b: 3.21E + 7 Decimal a with remainder_near () method: -3.14 Decimal b with rem ainder_near () method: 0E + 5 `