Python-number-floor
提供:Dev Guides
Python Number floor()メソッド
説明
Pythonの数値メソッド* floor()は、 *x の下限-x以下の最大整数を返します。
構文
以下は* floor()*メソッドの構文です-
import math
math.floor( x )
注-この関数は直接アクセスできないため、数学モジュールをインポートしてから、数学静的オブジェクトを使用してこの関数を呼び出す必要があります。
パラメーター
- x -これは数値式です。
戻り値
このメソッドは、x以下の最大整数を返します。
例
次の例は、floor()メソッドの使用方法を示しています。
#!/usr/bin/python
import math # This will import math module
print "math.floor(-45.17) : ", math.floor(-45.17)
print "math.floor(100.12) : ", math.floor(100.12)
print "math.floor(100.72) : ", math.floor(100.72)
print "math.floor(119L) : ", math.floor(119L)
print "math.floor(math.pi) : ", math.floor(math.pi)
上記のプログラムを実行すると、次の結果が生成されます-
math.floor(-45.17) : -46.0
math.floor(100.12) : 100.0
math.floor(100.72) : 100.0
math.floor(119L) : 119.0
math.floor(math.pi) : 3.0