Struct js_sys::Math

source ·
#[repr(transparent)]
pub struct Math { /* private fields */ }
Expand description

Implementations§

The Math.abs() function returns the absolute value of a number, that is Math.abs(x) = |x|

MDN documentation

The Math.acos() function returns the arccosine (in radians) of a number, that is ∀x∊[-1;1] Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x

MDN documentation

The Math.acosh() function returns the hyperbolic arc-cosine of a number, that is ∀x ≥ 1 Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x

MDN documentation

The Math.asin() function returns the arcsine (in radians) of a number, that is ∀x ∊ [-1;1] Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x

MDN documentation

The Math.asinh() function returns the hyperbolic arcsine of a number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x

MDN documentation

The Math.atan() function returns the arctangent (in radians) of a number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that tan(y) = x

The Math.atan2() function returns the arctangent of the quotient of its arguments.

MDN documentation

The Math.atanh() function returns the hyperbolic arctangent of a number, that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that tanh(y) = x

MDN documentation

The Math.cbrt() function returns the cube root of a number, that is Math.cbrt(x) = x^3 = the unique y such that y^3 = x

MDN documentation

The Math.ceil() function returns the smallest integer greater than or equal to a given number.

MDN documentation

The Math.clz32() function returns the number of leading zero bits in the 32-bit binary representation of a number.

MDN documentation

The Math.cos() static function returns the cosine of the specified angle, which must be specified in radians. This value is length(adjacent)/length(hypotenuse).

MDN documentation

The Math.cosh() function returns the hyperbolic cosine of a number, that can be expressed using the constant e.

MDN documentation

The Math.exp() function returns e^x, where x is the argument, and e is Euler’s number (also known as Napier’s constant), the base of the natural logarithms.

MDN documentation

The Math.expm1() function returns e^x - 1, where x is the argument, and e the base of the natural logarithms.

MDN documentation

The Math.floor() function returns the largest integer less than or equal to a given number.

MDN documentation

The Math.fround() function returns the nearest 32-bit single precision float representation of a Number.

MDN documentation

The Math.hypot() function returns the square root of the sum of squares of its arguments.

MDN documentation

The Math.imul() function returns the result of the C-like 32-bit multiplication of the two parameters.

MDN documentation

The Math.log() function returns the natural logarithm (base e) of a number. The JavaScript Math.log() function is equivalent to ln(x) in mathematics.

MDN documentation

The Math.log10() function returns the base 10 logarithm of a number.

MDN documentation

The Math.log1p() function returns the natural logarithm (base e) of 1 + a number. MDN documentation

The Math.log2() function returns the base 2 logarithm of a number.

MDN documentation

The Math.max() function returns the largest of two numbers.

MDN documentation

The static function Math.min() returns the lowest-valued number passed into it.

MDN documentation

The Math.pow() function returns the base to the exponent power, that is, base^exponent.

MDN documentation

The Math.random() function returns a floating-point, pseudo-random number in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.

MDN documentation

The Math.round() function returns the value of a number rounded to the nearest integer.

MDN documentation

The Math.sign() function returns the sign of a number, indicating whether the number is positive, negative or zero.

MDN documentation

The Math.sin() function returns the sine of a number.

MDN documentation

The Math.sinh() function returns the hyperbolic sine of a number, that can be expressed using the constant e: Math.sinh(x) = (e^x - e^-x)/2

MDN documentation

The Math.sqrt() function returns the square root of a number, that is ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x

MDN documentation

The Math.tan() function returns the tangent of a number.

MDN documentation

The Math.tanh() function returns the hyperbolic tangent of a number, that is tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)

MDN documentation

The Math.trunc() function returns the integer part of a number by removing any fractional digits.

MDN documentation

Methods from Deref<Target = Object>§

The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as its own property (as opposed to inheriting it).

MDN documentation

The isPrototypeOf() method checks if an object exists in another object’s prototype chain.

MDN documentation

The propertyIsEnumerable() method returns a Boolean indicating whether the specified property is enumerable.

MDN documentation

The toLocaleString() method returns a string representing the object. This method is meant to be overridden by derived objects for locale-specific purposes.

MDN documentation

The toString() method returns a string representing the object.

MDN documentation

The valueOf() method returns the primitive value of the specified object.

MDN documentation

Methods from Deref<Target = JsValue>§

Returns the f64 value of this JS value if it’s an instance of a number.

If this JS value is not an instance of a number then this returns None.

Tests whether this JS value is a JS string.

If this JS value is a string value, this function copies the JS string value into wasm linear memory, encoded as UTF-8, and returns it as a Rust String.

To avoid the copying and re-encoding, consider the JsString::try_from() function from js-sys instead.

If this JS value is not an instance of a string or if it’s not valid utf-8 then this returns None.

UTF-16 vs UTF-8

JavaScript strings in general are encoded as UTF-16, but Rust strings are encoded as UTF-8. This can cause the Rust string to look a bit different than the JS string sometimes. For more details see the documentation about the str type which contains a few caveats about the encodings.

Returns the bool value of this JS value if it’s an instance of a boolean.

If this JS value is not an instance of a boolean then this returns None.

Tests whether this JS value is null

Tests whether this JS value is undefined

Tests whether the type of this JS value is symbol

Tests whether typeof self == "object" && self !== null.

Tests whether the type of this JS value is function.

Tests whether the type of this JS value is bigint.

Applies the unary typeof JS operator on a JsValue.

MDN documentation

Applies the binary in JS operator on the two JsValues.

MDN documentation

Tests whether the value is “truthy”.

Tests whether the value is “falsy”.

Compare two JsValues for equality, using the == operator in JS.

MDN documentation

Applies the unary ~ JS operator on a JsValue.

MDN documentation

Applies the binary >>> JS operator on the two JsValues.

MDN documentation

Applies the binary / JS operator on two JsValues, catching and returning any RangeError thrown.

MDN documentation

Applies the binary ** JS operator on the two JsValues.

MDN documentation

Applies the binary < JS operator on the two JsValues.

MDN documentation

Applies the binary <= JS operator on the two JsValues.

MDN documentation

Applies the binary >= JS operator on the two JsValues.

MDN documentation

Applies the binary > JS operator on the two JsValues.

MDN documentation

Applies the unary + JS operator on a JsValue. Can throw.

MDN documentation

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
Recover a Self from Self::Abi. Read more
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
Convert self into Self::Abi so that it can be sent across the wasm ABI boundary. Read more
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
Convert self into Self::Abi so that it can be sent across the wasm ABI boundary. Read more
Performs a dynamic instanceof check to see whether the JsValue provided is an instance of this type. Read more
Performs a zero-cost unchecked conversion from a JsValue into an instance of Self Read more
Performs a zero-cost unchecked conversion from a &JsValue into an instance of &Self. Read more
Test whether this JS value has a type T. Read more
Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
Performs a zero-cost unchecked cast into the specified type. Read more
Performs a zero-cost unchecked cast into a reference to the specified type. Read more
Test whether this JS value is an instance of the type T. Read more
Performs a dynamic check to see whether the JsValue provided is a value of this type. Read more
Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi. Read more
Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
The wasm ABI type references to Self are recovered from.
The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous. Read more
Recover a Self::Anchor from Self::Abi. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Same as IntoWasmAbi::Abi
Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.