package quickjs

  1. Overview
  2. Docs

Module Quickjs.NumberSource

JavaScript Number built-in object

This module mirrors the JavaScript Number API with prototype methods for number-to-string conversion.

Sourcetype format =
  1. | Free
    (*

    Use minimum digits needed for exact round-trip

    *)
  2. | Fixed of int
    (*

    Use n significant digits (1-101)

    *)
  3. | Fractional of int
    (*

    Use n fractional digits (0-101)

    *)

Number of digits to use

Sourcetype exponent =
  1. | Auto
    (*

    Use exponential when appropriate

    *)
  2. | Always
    (*

    Always use exponential notation

    *)
  3. | Never
    (*

    Never use exponential notation

    *)

Exponential notation control

Sourcetype options = {
  1. format : format;
  2. exponent : exponent;
  3. radix : int;
  4. show_minus_zero : bool;
}

Full options for formatting

Sourceval default_options : options

Default options: Free format, Auto exponent, radix 10, no minus zero

Sourcemodule Prototype : sig ... end

Number.prototype methods

Integer-to-string conversions

Sourceval of_int : int -> string

of_int n converts integer n to string.

Sourceval of_int32 : int32 -> string

of_int32 n converts 32-bit integer n to string.

Sourceval of_int64 : int64 -> string

of_int64 n converts 64-bit integer n to string.

Sourceval of_uint32 : Unsigned.UInt32.t -> string

of_uint32 n converts unsigned 32-bit integer n to string.

Sourceval of_uint64 : Unsigned.UInt64.t -> string

of_uint64 n converts unsigned 64-bit integer n to string.

Sourceval of_int_radix : radix:int -> int -> string

of_int_radix ~radix n converts integer n to string in given radix.

Sourceval of_int32_radix : radix:int -> int32 -> string

of_int32_radix ~radix n converts 32-bit integer n to string in given radix.

Sourceval of_int64_radix : radix:int -> int64 -> string

of_int64_radix ~radix n converts 64-bit integer n to string in given radix.