Number

Wrappers for basic numerical values.

The Number object has been split into one class per basic WebAssembly type as well. Unlike in JavaScript, these classes cannot have actual instances.

API

The Number API works a bit different than JavaScript's (MDN).

It is planned to pick up the instance members described below automatically, for example when concatenating a string with a number, but this is not yet functional.

Integers

The name Number below stands for one of I8, I16, I32, I64, U8, U16, U32 or U64 representing their respective basic type T.

Static

  • Number.MIN_VALUE: T readonly The smallest representable value within the respective basic type. This differs from floating point values where this is the smallest representable positive value.

  • Number.MAX_VALUE: T readonly The largest representable value within the respective basic type.

  • Number.parseInt(value: string, radix?: i32): T Parses a string to a value of the respective basic type.

Instance

  • Number#toString(radix?: i32): string Returns the respective basic value converted to a string. The radix parameter is not supported yet.

Floats

The name Number below stands for one of F32 or F64 representing their respective basic type T.

Static

  • Number.EPSILON: T readonly The difference between 1.0 and the smallest number larger than 1.0.

  • Number.MAX_VALUE: T readonly The largest representable positive value within the respective basic type.

  • Number.MIN_VALUE: T readonly The smallest representable positive value within the respective basic type.

  • Number.MAX_SAFE_INTEGER: T readonly The largest safe integer representable by the respective basic type.

  • Number.MIN_SAFE_INTEGER: T readonly The smallest safe integer representable by the respective basic type.

  • Number.POSITIVE_INFINITY: T readonly Positive infinity within the respective basic type.

  • Number.NEGATIVE_INFINITY: T readonly Negative infinity within the respective basic type.

  • Number.NaN: T readonly NaN (Not A Number) in the respective basic type.

  • Number.isNan(value: T): bool Tests if the value is Number.NaN.

  • Number.isFinite(value: T): bool Tests if the value is finite, that is not Number.NaN , Number.POSITIVE_INFINITY or Number.NEGATIVE_INFINITY.

  • Number.isInteger(value: T): bool Tests if the value is an integer.

  • Number.isSafeInteger(value: T): bool Tests if the value is a safe integer.

  • Number.parseInt(value: string, radix?: i32): T Parses a string to an integer value of the respective basic type.

  • Number.parseFloat(value: string): T Parses a string to a float value of the respective basic type.

Instance

  • Number#toString(radix?: i32): string Returns the respective basic value converted to a string. The radix parameter is not supported yet.