Number

Overview

A Number represents any 63-bit floating-point number. Internally, all values are encoded as tagged pointers where pointers with an initial bit of zero denote a floating-point value. As such, it should be noted there will be a minor loss of precision, approximately 15 decimal digits instead of ~15.95 for a full 64-bit double, with a mantissa of 51-bits.

Fields

.sign

fn -> Number

Gets the signum of a Number.

.abs

fn -> Number

Gets the absolute value of a Number.

.ceil

fn -> Number

Rounds a Number up to its nearest integer value.

.floor

fn -> Number

Rounds a Number down to its nearest integer value.

.round

fn -> Number

Rounds a Number to its nearest integer value.

.trunc

fn -> Number

Returns the integer part of a Number by removing any fractional digits.

.clamp

fn (minimum?: Number, maximum?: Number) -> Number

Ensures a Number is between two values, otherwise it returns the nearest boundary.

.is_nan

fn -> Boolean

Determines if a Number is represented by a NaN value.

.is_fin

fn -> Boolean

Determines if a Number is represented by a finite value.

.is_inf

fn -> Boolean

Determines if a Number is represented by an infinite value.

.to_precision

fn (digits?: Number) -> String

Converts a Number to a String with an optional number of significant digits.

.to_scientific

fn (digits?: Number) -> String

Converts a Number to a scientific String representation with an optional number of significant digits.

Statics

.parse

fn (input: String, radix?: Number) -> Number

Parses an input String, as a possible Number value. A radix value can be given to ensure parsing integer only values.

On this page