StrictMath Class

Definition

The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

[Android.Runtime.Register("java/lang/StrictMath", DoNotGenerateAcw=true)]
public sealed class StrictMath : Java.Lang.Object
[<Android.Runtime.Register("java/lang/StrictMath", DoNotGenerateAcw=true)>]
type StrictMath = class
    inherit Object
Inheritance
StrictMath
Attributes

Remarks

The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

To help ensure portability of Java programs, the definitions of some of the numeric functions in this package require that they produce the same results as certain published algorithms. These algorithms are available from the well-known network library netlib as the package "Freely Distributable Math Library," fdlibmhttps://www.netlib.org/fdlibm/. These algorithms, which are written in the C programming language, are then to be understood as executed with all floating-point operations following the rules of Java floating-point arithmetic.

The Java math library is defined with respect to fdlibm version 5.3. Where fdlibm provides more than one definition for a function (such as acos), use the "IEEE 754 core function" version (residing in a file whose name begins with the letter e). The methods which require fdlibm semantics are sin, cos, tan, asin, acos, atan, exp, log, log10, cbrt, atan2, pow, sinh, cosh, tanh, hypot, expm1, and log1p.

The platform uses signed two's complement integer arithmetic with int and long primitive types. The developer should choose the primitive type to ensure that arithmetic operations consistently produce correct results, which in some cases means the operations will not overflow the range of values of the computation. The best practice is to choose the primitive type and algorithm to avoid overflow. In cases where the size is int or long and overflow errors need to be detected, the methods addExact, subtractExact, multiplyExact, toIntExact, incrementExact, decrementExact and negateExact throw an ArithmeticException when the results overflow. For the arithmetic operations divide and absolute value, overflow occurs only with a specific minimum or maximum value and should be checked against the minimum or maximum as appropriate.

<h2>Ieee754RecommendedOps>IEEE 754 Recommended Operations</h2>

The java.lang.Math Math class discusses how the shared quality of implementation criteria for selected Math and StrictMath methods relate to the IEEE 754 recommended operations.

Added in 1.3.

Java documentation for java.lang.StrictMath.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

E

The double value that is closer than any other to e, the base of the natural logarithms.

Pi

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Abs(Double)

Returns the absolute value of a double value.

Abs(Int32)

Returns the absolute value of an int value.

Abs(Int64)

Returns the absolute value of a long value.

Abs(Single)

Returns the absolute value of a float value.

AbsExact(Int32)

Returns the mathematical absolute value of an int value if it is exactly representable as an int, throwing ArithmeticException if the result overflows the positive int range.

AbsExact(Int64)

Returns the mathematical absolute value of an long value if it is exactly representable as an long, throwing ArithmeticException if the result overflows the positive long range.

Acos(Double)

Returns the arc cosine of a value; the returned angle is in the range 0.

AddExact(Int32, Int32)

Returns the sum of its arguments, throwing an exception if the result overflows an int.

AddExact(Int64, Int64)

Returns the sum of its arguments, throwing an exception if the result overflows a long.

Asin(Double)

Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.

Atan(Double)

Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.

Atan2(Double, Double)

Returns the angle theta from the conversion of rectangular coordinates (x,&nbsp;y) to polar coordinates (r,&nbsp;theta).

Cbrt(Double)

Returns the cube root of a double value.

Ceil(Double)

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CopySign(Double, Double)

Returns the first floating-point argument with the sign of the second floating-point argument.

CopySign(Single, Single)

Returns the first floating-point argument with the sign of the second floating-point argument.

Cos(Double)

Returns the trigonometric cosine of an angle.

Cosh(Double)

Returns the hyperbolic cosine of a double value.

DecrementExact(Int32)

Returns the argument decremented by one, throwing an exception if the result overflows an int.

DecrementExact(Int64)

Returns the argument decremented by one, throwing an exception if the result overflows a long.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Exp(Double)

Returns Euler's number e raised to the power of a double value.

Expm1(Double)

Returns e<sup>x</sup>&nbsp;-1.

Floor(Double)

Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

FloorDiv(Int32, Int32)

Returns the largest (closest to positive infinity) int value that is less than or equal to the algebraic quotient.

FloorDiv(Int64, Int32)

Returns the largest (closest to positive infinity) long value that is less than or equal to the algebraic quotient.

FloorDiv(Int64, Int64)

Returns the largest (closest to positive infinity) long value that is less than or equal to the algebraic quotient.

FloorMod(Int32, Int32)

Returns the floor modulus of the int arguments.

FloorMod(Int64, Int32)

Returns the floor modulus of the long and int arguments.

FloorMod(Int64, Int64)

Returns the floor modulus of the long arguments.

Fma(Double, Double, Double)

Returns the fused multiply add of the three arguments; that is, returns the exact product of the first two arguments summed with the third argument and then rounded once to the nearest double.

Fma(Single, Single, Single)

Returns the fused multiply add of the three arguments; that is, returns the exact product of the first two arguments summed with the third argument and then rounded once to the nearest float.

GetExponent(Double)

Returns the unbiased exponent used in the representation of a double.

GetExponent(Single)

Returns the unbiased exponent used in the representation of a float.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Hypot(Double, Double)

Returns sqrt(x<sup>2</sup>&nbsp;+y<sup>2</sup>) without intermediate overflow or underflow.

IEEEremainder(Double, Double)

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.

IncrementExact(Int32)

Returns the argument incremented by one, throwing an exception if the result overflows an int.

IncrementExact(Int64)

Returns the argument incremented by one, throwing an exception if the result overflows a long.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Log(Double)

Returns the natural logarithm (base e) of a double value.

Log10(Double)

Returns the base 10 logarithm of a double value.

Log1p(Double)

Returns the natural logarithm of the sum of the argument and 1.

Max(Double, Double)

Returns the greater of two double values.

Max(Int32, Int32)

Returns the greater of two int values.

Max(Int64, Int64)

Returns the greater of two long values.

Max(Single, Single)

Returns the greater of two float values.

Min(Double, Double)

Returns the smaller of two double values.

Min(Int32, Int32)

Returns the smaller of two int values.

Min(Int64, Int64)

Returns the smaller of two long values.

Min(Single, Single)

Returns the smaller of two float values.

MultiplyExact(Int32, Int32)

Returns the product of the arguments, throwing an exception if the result overflows an int.

MultiplyExact(Int64, Int32)

Returns the product of the arguments, throwing an exception if the result overflows a long.

MultiplyExact(Int64, Int64)

Returns the product of the arguments, throwing an exception if the result overflows a long.

MultiplyFull(Int32, Int32)

Returns the exact mathematical product of the arguments.

MultiplyHigh(Int64, Int64)

Returns as a long the most significant 64 bits of the 128-bit product of two 64-bit factors.

NegateExact(Int32)

Returns the negation of the argument, throwing an exception if the result overflows an int.

NegateExact(Int64)

Returns the negation of the argument, throwing an exception if the result overflows a long.

NextAfter(Double, Double)

Returns the floating-point number adjacent to the first argument in the direction of the second argument.

NextAfter(Single, Double)

Returns the floating-point number adjacent to the first argument in the direction of the second argument.

NextDown(Double)

Returns the floating-point value adjacent to d in the direction of negative infinity.

NextDown(Single)

Returns the floating-point value adjacent to f in the direction of negative infinity.

NextUp(Double)

Returns the floating-point value adjacent to d in the direction of positive infinity.

NextUp(Single)

Returns the floating-point value adjacent to f in the direction of positive infinity.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Pow(Double, Double)

Returns the value of the first argument raised to the power of the second argument.

Random()

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.

Rint(Double)

Returns the double value that is closest in value to the argument and is equal to a mathematical integer.

Round(Double)

Returns the closest long to the argument, with ties rounding to positive infinity.

Round(Single)

Returns the closest int to the argument, with ties rounding to positive infinity.

Scalb(Double, Int32)

Returns d &times; 2<sup>scaleFactor</sup> rounded as if performed by a single correctly rounded floating-point multiply.

Scalb(Single, Int32)

Returns f &times; 2<sup>scaleFactor</sup> rounded as if performed by a single correctly rounded floating-point multiply.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
Signum(Double)

Returns the signum function of the argument; zero if the argument is zero, 1.

Signum(Single)

Returns the signum function of the argument; zero if the argument is zero, 1.

Sin(Double)

Returns the trigonometric sine of an angle.

Sinh(Double)

Returns the hyperbolic sine of a double value.

Sqrt(Double)

Returns the correctly rounded positive square root of a double value.

SubtractExact(Int32, Int32)

Returns the difference of the arguments, throwing an exception if the result overflows an int.

SubtractExact(Int64, Int64)

Returns the difference of the arguments, throwing an exception if the result overflows a long.

Tan(Double)

Returns the trigonometric tangent of an angle.

Tanh(Double)

Returns the hyperbolic tangent of a double value.

ToArray<T>() (Inherited from Object)
ToDegrees(Double)

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

ToIntExact(Int64)

Returns the value of the long argument, throwing an exception if the value overflows an int.

ToRadians(Double)

Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

ToString()

Returns a string representation of the object.

(Inherited from Object)
Ulp(Double)

Returns the size of an ulp of the argument.

Ulp(Single)

Returns the size of an ulp of the argument.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to