この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Math クラス

算術演算のメソッドが含まれます。

名前空間

System

計算項目

Math の項目は次のとおりです。

E

自然対数の底である数学定数 e を返します。

署名

public static final Double E

プロパティ���

型: Double

PI

円周率である数学定数 pi を返します。

署名

public static final Double PI

プロパティ値

型: Double

Math メソッド

Math のメソッドは次のとおりです。すべてのメソッドが静的です。

abs(decimalValue)

指定された decimal の絶対値を返します。

署名

public static Decimal abs(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

abs(doubleValue)

指定された double の絶対値を返します。

署名

public static Double abs(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

abs(integerValue)

指定された integer の絶対値を返します。

署名

public static Integer abs(Integer integerValue)

パラメータ

integerValue
型: Integer

戻り値

型: Integer

1Integer i = -42;
2Integer i2 = math.abs(i);
3system.assertEquals(i2, 42);

abs(longValue)

指定された long の絶対値を返します。

署名

public static Long abs(Long longValue)

パラメータ

longValue
型: Long

戻り値

型: Long

acos(decimalAngle)

角のアークコサインを 0.0 ~ pi の範囲で返します。

署名

public static Decimal acos(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

acos(doubleAngle)

角のアークコサインを 0.0 ~ pi の範囲で返します。

署名

public static Double acos(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

asin(decimalAngle)

角のアークサインを -pi/2 ~ pi/2 の範囲で返します。

署名

public static Decimal asin(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

asin(doubleAngle)

角のアークサインを -pi/2 ~ pi/2 の範囲で返します。

署名

public static Double asin(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

atan(decimalAngle)

角のアークタンジェントを -pi/2 ~ pi/2 の範囲で返します。

署名

public static Decimal atan(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

atan(doubleAngle)

角のアークタンジェントを -pi/2 ~ pi/2 の範囲で返します。

署名

public static Double atan(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

atan2(xCoordinate, yCoordinate)

直交座標 (xCoordinate および yCoordinate) を極 (r および theta) に変換します。このメソッドは、xCoordinate/yCoordinate のアークタンジェントを -pipi の範囲で計算することで、相 theta を計算します。

署名

public static Decimal atan2(Decimal xCoordinate, Decimal yCoordinate)

パラメータ

xCoordinate
型: Decimal
yCoordinate
型: Decimal

戻り値

型: Decimal

atan2(xCoordinate, yCoordinate)

直交座標 (xCoordinate および yCoordinate) を極 (r および theta) に変換します。このメソッドは、xCoordinate/yCoordinate のアークタンジェントを -pipi の範囲で計算することで、相 theta を計算します。

署名

public static Double atan2(Double xCoordinate, Double yCoordinate)

パラメータ

xCoordinate
型: Double
yCoordinate
型: Double

戻り値

型: Double

cbrt(decimalValue)

指定された decimal の立方根を返します。負の値の立方根は、値の大きさの平方根を負にしたものです。

署名

public static Decimal cbrt(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

cbrt(doubleValue)

指定された double の立方根を返します。負の値の立方根は、値の大きさの平方根を負にしたものです。

署名

public static Double cbrt(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

ceil(decimalValue)

最も小さい (負の無限大に最も近い) decimal を返します。引数より大きく、数学的整数と等しい値になります。

署名

public static Decimal ceil(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

ceil(doubleValue)

最も小さい (負の無限大に最も近い) double を返します。引数より大きく、数学的整数と等しい値になります。

署名

public static Double ceil(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

cos(decimalAngle)

decimalAngle で指定された角の三角関数のコサインを返します。

署名

public static Decimal cos(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

cos(doubleAngle)

doubleAngle で指定された角の三角関数のコサインを返します。

署名

public static Double cos(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

cosh(decimalAngle)

decimalAngle の双曲線コサインを返します。d の双曲線コサインは、(ex + e-x)/2 となるように定義します。ここで e はオイラーの数値です。

署名

public static Decimal cosh(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

cosh(doubleAngle)

doubleAngle の双曲線コサインを返します。d の双曲線コサインは、(ex + e-x)/2 となるように定義します。ここで e はオイラーの数値です。

署名

public static Double cosh(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

exp(exponentDecimal)

指定した decimal の累乗まで乗算したオイラーの数値 e を返します。

署名

public static Decimal exp(Decimal exponentDecimal)

パラメータ

exponentDecimal
型: Decimal

戻り値

型: Decimal

exp(exponentDouble)

指定した double の累乗まで乗算したオイラーの数値 e を返します。

署名

public static Double exp(Double exponentDouble)

パラメータ

exponentDouble
型: Double

戻り値

型: Double

floor(decimalValue)

最も大きい (正の無限大に最も近い) decimal を返します。引数より小さく、数学的整数と等しい値になります。

署名

public static Decimal floor(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

floor(doubleValue)

最も大きい (正の無限大に最も近い) double を返します。引数より小さく、数学的整数と等しい値になります。

署名

public static Double floor(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

log(decimalValue)

指定された decimal の自然対数 (base e) を返します。

署名

public static Decimal log(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

log(doubleValue)

指定された double の自然対数 (base e) を返します。

署名

public static Double log(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

log10(decimalValue)

指定された decimal の対数 (base 10) を返します。

署名

public static Decimal log10(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

log10(doubleValue)

指定された double の対数 (base 10) を返します。

署名

public static Double log10(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

max(decimalValue1, decimalValue2)

指定された 2 つの decimal の大きい方を返します。

署名

public static Decimal max(Decimal decimalValue1, Decimal decimalValue2)

パラメータ

decimalValue1
型: Decimal
decimalValue2
型: Decimal

戻り値

型: Decimal

1Decimal larger = math.max(12.3, 156.6);
2system.assertEquals(larger, 156.6);

max(doubleValue1, doubleValue2)

指定された 2 つの double の大きい方を返します。

署名

public static Double max(Double doubleValue1, Double doubleValue2)

パラメータ

doubleValue1
型: Double
doubleValue2
型: Double

戻り値

型: Double

max(integerValue1, integerValue2)

指定された 2 つの integer の大きい方を返します。

署名

public static Integer max(Integer integerValue1, Integer integerValue2)

パラメータ

integerValue1
型: Integer
integerValue2
型: Integer

戻り値

型: Integer

max(longValue1, longValue2)

指定された 2 つの long の大きい方を返します。

署名

public static Long max(Long longValue1, Long longValue2)

パラメータ

longValue1
型: Long
longValue2
型: Long

戻り値

型: Long

min(decimalValue1, decimalValue2)

指定された 2 つの decimal の小さい方を返します。

署名

public static Decimal min(Decimal decimalValue1, Decimal decimalValue2)

パラメータ

decimalValue1
型: Decimal
decimalValue2
型: Decimal

戻り値

型: Decimal

1Decimal smaller = math.min(12.3, 156.6);
2system.assertEquals(smaller, 12.3);

min(doubleValue1, doubleValue2)

指定された 2 つの double の小さい方を返します。

署名

public static Double min(Double doubleValue1, Double doubleValue2)

パラメータ

doubleValue1
型: Double
doubleValue2
型: Double

戻り値

型: Double

min(integerValue1, integerValue2)

指定された 2 つの integer の小さい方を返します。

署名

public static Integer min(Integer integerValue1, Integer integerValue2)

パラメータ

integerValue1
型: Integer
integerValue2
型: Integer

戻り値

型: Integer

min(longValue1, longValue2)

指定された 2 つの long の小さい方を返します。

署名

public static Long min(Long longValue1, Long longValue2)

パラメータ

longValue1
型: Long
longValue2
型: Long

戻り値

型: Long

mod(integerValue1, integerValue2)

integerValue1integerValue2 で除算した余りを返します。

署名

public static Integer mod(Integer integerValue1, Integer integerValue2)

パラメータ

integerValue1
型: Integer
integerValue2
型: Integer

戻り値

型: Integer

1Integer remainder = math.mod(12, 2);
2system.assertEquals(remainder, 0);
3
4Integer remainder2 = math.mod(8, 3);
5system.assertEquals(remainder2, 2);

mod(longValue1, longValue2)

longValue2longValue2 で除算した余りを返します。

署名

public static Long mod(Long longValue1, Long longValue2)

パラメータ

longValue1
型: Long
longValue2
型: Long

戻り値

型: Long

pow(doubleValue, exponent)

exponent の累乗まで乗算した最初の double 値を返します。

署名

public static Double pow(Double doubleValue, Double exponent)

パラメータ

doubleValue
型: Double
exponent
型: Double

戻り値

型: Double

random()

0.0 以上 1.0 未満の正の double を返します。

署名

public static Double random()

戻り値

型: Double

rint(decimalValue)

decimalValue に最も近く、数学的整数と等しい値を返します。

署名

public static Decimal rint(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

rint(doubleValue)

doubleValue に最も近く、数学的整数と等しい値を返します。

署名

public static Double rint(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

round(doubleValue)

使用しません。このメソッドは、Winter '08 リリースの時点で廃止されています。代わりに、Math.roundToLong を使用してください。指定された double に最も近い integer を返します。結果が -2,147,483,648 未満または 2,147,483,647 より大きい場合、Apex はエラーを生成します。

署名

public static Integer round(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Integer

round(decimalValue)

decimal の丸められた近似値を返します。数値は、均等丸めモードを使用して、「最も近い近似値」である整数に丸められます。ただし、2 つの近似値が等距離にある場合は、このモードでは偶数の近似値に丸められます。

署名

public static Integer round(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Integer

使用方法

この丸めモードは、連続する計算に対して繰り返し適用される場合、統計的に累積エラーを最小化します。

1Decimal d1 = 4.5;
2Integer i1 = Math.round(d1);
3System.assertEquals(4, i1);
4
5Decimal d2 = 5.5;
6Integer i2 = Math.round(d2);
7System.assertEquals(6, i2);

roundToLong(decimalValue)

decimal の丸められた近似値を返します。数値は、均等丸めモードを使用して、「最も近い近似値」である整数に丸められます。ただし、2 つの近似値が等距離にある場合は、このモードでは偶数の近似値に丸められます。

署名

public static Long roundToLong(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Long

使用方法

この丸めモードは、連続する計算に対して繰り返し適用される場合、統計的に累積エラーを最小化します。

1Decimal d1 = 4.5;
2Long i1 = Math.roundToLong(d1);
3System.assertEquals(4, i1);
4
5Decimal d2 = 5.5;
6Long i2 = Math.roundToLong(d2);
7System.assertEquals(6, i2);

roundToLong(doubleValue)

指定された double に最も近い long を返します。

署名

public static Long roundToLong(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Long

signum(decimalValue)

指定された decimal の符号関数を返します。decimalValue が 0 の場合は 0、decimalValue が 0 より大きい場合は 1.0、decimalValue が 0 より小さい場合は -1.0 です。

署名

public static Decimal signum(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

signum(doubleValue)

指定された double の符号関数を返します。doubleValue が 0 の場合は 0、doubleValue が 0 より大きい場合は 1.0、doubleValue が 0 より小さい場合は -1.0 です。

署名

public static Double signum(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

sin(decimalAngle)

decimalAngle で指定された角の三角関数のサインを返します。

署名

public static Decimal sin(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

sin(doubleAngle)

doubleAngle で指定された角の三角関数のサインを返します。

署名

public static Double sin(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

sinh(decimalAngle)

decimalAngle の双曲線サインを返します。decimalAngle の双曲線サインは、(ex + e-x)/2 となるように定義します。ここで e はオイラーの数値です。

署名

public static Decimal sinh(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

sinh(doubleAngle)

doubleAngle の双曲線サインを返します。doubleAngle の双曲線サインは、(ex + e-x)/2 となるように定義します。ここで e はオイラーの数値です。

署名

public static Double sinh(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

sqrt(decimalValue)

適切に丸められた decimalValue の正の平方根を返します。

署名

public static Decimal sqrt(Decimal decimalValue)

パラメータ

decimalValue
型: Decimal

戻り値

型: Decimal

sqrt(doubleValue)

適切に丸められた doubleValue の正の平方根を返します。

署名

public static Double sqrt(Double doubleValue)

パラメータ

doubleValue
型: Double

戻り値

型: Double

tan(decimalAngle)

decimalAngle で指定された角の三角関数のタンジェントを返します。

署名

public static Decimal tan(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

tan(doubleAngle)

doubleAngle で指定された角の三角関数のタンジェントを返します。

署名

public static Double tan(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double

tanh(decimalAngle)

decimalAngle の双曲線タンジェントを返します。decimalAngle の双曲線タンジェントは (ex - e-x)/(ex + e-x) となるように定義します。ここで e はオイラーの数値です。つまり、sinh(x)/cosinh(x) と等しくなります。正確な tanh の絶対値は常に 1 より小さい値です。

署名

public static Decimal tanh(Decimal decimalAngle)

パラメータ

decimalAngle
型: Decimal

戻り値

型: Decimal

tanh(doubleAngle)

doubleAngle の双曲線タンジェントを返します。doubleAngle の双曲線タンジェントは (ex - e-x)/(ex + e-x) となるように定義します。ここで e はオイラーの数値です。つまり、sinh(x)/cosinh(x) と等しくなります。正確な tanh の絶対値は常に 1 より小さい値です。

署名

public static Double tanh(Double doubleAngle)

パラメータ

doubleAngle
型: Double

戻り値

型: Double