Decimal#next_plus() : next_plus() es un método de clase Decimal que devuelve el número representable más pequeño mayor que el valor Decimal.
Sintaxis: Decimal.next_plus()
Parámetro: Valores decimales
Devuelve: el menor número representable mayor que el valor Decimal.
Código #1: Ejemplo para el método next_plus()
# Python Program explaining # next_plus() method # loading decimal library from decimal import * # Initializing a decimal value a = Decimal(-1) b = Decimal('0.142857') # printing Decimal values print ("Decimal value a : ", a) print ("Decimal value b : ", b) # Using Decimal.next_plus() method print ("\n\nDecimal a with next_plus() method : ", a.next_plus()) print ("Decimal a with next_plus() method : ", a.next_plus()) print ("Decimal b with next_plus() method : ", b.next_plus())
Producción :
Decimal value a : -1 Decimal value b : 0.142857 Decimal a with next_plus() method : -0.9999999999999999999999999999 Decimal a with next_plus() method : -0.9999999999999999999999999999 Decimal b with next_plus() method : 0.1428570000000000000000000001
Código #2: Ejemplo para el método next_plus()
# Python Program explaining # next_plus() method # loading decimal library from decimal import * # Initializing a decimal value a = Decimal('-3.14') b = Decimal('321e + 5') # printing Decimal values print ("Decimal value a : ", a) print ("Decimal value b : ", b) # Using Decimal.next_plus() method print ("\n\nDecimal a with next_plus() method : ", a.next_plus()) print ("Decimal a with next_plus() method : ", a.next_plus()) print ("Decimal b with next_plus() method : ", b.next_plus())
Producción :
Decimal value a : -3.14 Decimal value b : 3.21E+7 Decimal a with next_plus() method : -3.139999999999999999999999999 Decimal a with next_plus() method : -3.139999999999999999999999999 Decimal b with next_plus() method : 32100000.00000000000000000001
Publicación traducida automáticamente
Artículo escrito por noobestars101 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA