指定された数以下の数のうち、最大の整数を返します。
Public Shared Function Floor( _
ByVal d As Double _) As Double
[C#]
public static double Floor(doubled);
[C++]
public: static double Floor(doubled);
[JScript]
public static function Floor(
d : double) : double;
パラメータ
- d
数値。
戻り値
d 以下で、最大の整数。 d が NaN 、 NegativeInfinity 、 PositiveInfinity のいずれかに等しい場合は、その値が返されます。
解説
このメソッドの動作は IEEE 規格 754、セクション 4 に従います。このような丸めは、負の無限大への丸めと呼ばれることがあります。
使用例
' This example demonstrates Math.Ceiling()
' Math.Floor()
Imports System
Class Sample
Public Shared Sub Main()
Dim value As Double
Dim nl As String = Environment.NewLine
' Return the smallest whole number greater than or equal to the
' specified number.
' Note that the results are affected by the precision of the floating point
' number, value.
Console.WriteLine("{0}Ceiling:", nl)
For value = 0.0 To 1.1 Step 0.1
Console.WriteLine("Ceiling({0:f}) = {1}", value, Math.Ceiling(value))
Next value
' Return the largest whole number less than or equal to the specified
' number.
' Note that the results are affected by the precision of the floating point
' number, value.
Console.WriteLine("{0}Floor:", nl)
For value = 2.1 To 0.9 Step -0.1
Console.WriteLine("Floor({0:f}) = {1}", value, Math.Floor(value))
Next value
End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'Ceiling:
'Ceiling(0.00) = 0
'Ceiling(0.10) = 1
'Ceiling(0.20) = 1
'Ceiling(0.30) = 1
'Ceiling(0.40) = 1
'Ceiling(0.50) = 1
'Ceiling(0.60) = 1
'Ceiling(0.70) = 1
'Ceiling(0.80) = 1
'Ceiling(0.90) = 1
'Ceiling(1.00) = 1
'Ceiling(1.10) = 2
'
'Floor:
'Floor(2.10) = 2
'Floor(2.00) = 2
'Floor(1.90) = 1
'Floor(1.80) = 1
'Floor(1.70) = 1
'Floor(1.60) = 1
'Floor(1.50) = 1
'Floor(1.40) = 1
'Floor(1.30) = 1
'Floor(1.20) = 1
'Floor(1.10) = 1
'Floor(1.00) = 0
'
[C#]
// This example demonstrates Math.Ceiling()
// Math.Floor()
using System;
class Sample
{
public static void Main()
{
double value;
string nl = Environment.NewLine;
// Return the smallest whole number greater than or equal to the
// specified number.
// Note that the results are affected by the precision of the floating point
// number, value.
Console.WriteLine("{0}Ceiling:", nl);
for (value = 0.0; value <= 1.1; value += 0.1)
Console.WriteLine("Ceiling({0:f}) = {1}", value, Math.Ceiling(value));
// Return the largest whole number less than or equal to the specified
// number.
// Note that the results are affected by the precision of the floating point
// number, value.
Console.WriteLine("{0}Floor:", nl);
for (value = 2.1; value >= 0.9; value -= 0.1)
Console.WriteLine("Floor({0:f}) = {1}", value, Math.Floor(value));
}
}
/*
This example produces the following results:
Ceiling:
Ceiling(0.00) = 0
Ceiling(0.10) = 1
Ceiling(0.20) = 1
Ceiling(0.30) = 1
Ceiling(0.40) = 1
Ceiling(0.50) = 1
Ceiling(0.60) = 1
Ceiling(0.70) = 1
Ceiling(0.80) = 1
Ceiling(0.90) = 1
Ceiling(1.00) = 1
Ceiling(1.10) = 2
Floor:
Floor(2.10) = 2
Floor(2.00) = 2
Floor(1.90) = 1
Floor(1.80) = 1
Floor(1.70) = 1
Floor(1.60) = 1
Floor(1.50) = 1
Floor(1.40) = 1
Floor(1.30) = 1
Floor(1.20) = 1
Floor(1.10) = 1
Floor(1.00) = 0
*/
[C++]
// This example demonstrates Math.Ceiling()
// Math.Floor()
#using <mscorlib.dll>
using namespace System;
int main()
{
double value;
String* nl = Environment::NewLine;
// Return the smallest whole number greater than or equal to the
// specified number.
// Note that the results are affected by the precision of the floating point
// number, value.
Console::WriteLine(S"{0}Ceiling:", nl);
for (value = 0.0; value <= 1.1; value += 0.1)
Console::WriteLine(S"Ceiling({0:f}) = {1}", __box(value), __box(Math::Ceiling(value)));
// Return the largest whole number less than or equal to the specified
// number.
// Note that the results are affected by the precision of the floating point
// number, value.
Console::WriteLine(S"{0}Floor:", nl);
for (value = 2.1; value >= 0.9; value -= 0.1)
Console::WriteLine(S"Floor({0:f}) = {1}", __box(value), __box(Math::Floor(value)));
}
/*
This example produces the following results:
Ceiling:
Ceiling(0.00) = 0
Ceiling(0.10) = 1
Ceiling(0.20) = 1
Ceiling(0.30) = 1
Ceiling(0.40) = 1
Ceiling(0.50) = 1
Ceiling(0.60) = 1
Ceiling(0.70) = 1
Ceiling(0.80) = 1
Ceiling(0.90) = 1
Ceiling(1.00) = 1
Ceiling(1.10) = 2
Floor:
Floor(2.10) = 2
Floor(2.00) = 2
Floor(1.90) = 1
Floor(1.80) = 1
Floor(1.70) = 1
Floor(1.60) = 1
Floor(1.50) = 1
Floor(1.40) = 1
Floor(1.30) = 1
Floor(1.20) = 1
Floor(1.10) = 1
Floor(1.00) = 0
*/
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard
参照
Math クラス | Math メンバ | System 名前空間 | Round | Ceiling