def floor(value: int|float) -> int
-3.14
est -4
car cette dernière est inférieure à -3.14
.
Return the floor of x as an Integral. This is the largest integer <= x.
Paramètre | Description |
---|---|
value : int|float |
La valeur à partir de laquelle calculer l'arrondi « plancher ». |
La valeur de retour est de type int.
La valeur de retour correspond à l'arrondi entier inférieur (l'arrondi plancher).
TypeError :Une exception de ce type sera déclenchée si la valeur passée en paramètre n'est pas numérique
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/usr/bin/python3 import math value = 4.7 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) value = 4.1 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) value = 4.0 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) value = 0 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) value = -1.3 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) value = -1.9 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) value = -2 print("Math.floor( %.1f ) == %d" % (value, math.floor(value))) |
Et voici un exemple d'exécution de ce programme :
Math.floor( 4.7 ) == 4 Math.floor( 4.1 ) == 4 Math.floor( 4.0 ) == 4 Math.floor( 0.0 ) == 0 Math.floor( -1.3 ) == -2 Math.floor( -1.9 ) == -2 Math.floor( -2.0 ) == -2
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :