Skip to main content

Float

Reference for mo:core/Float in the core library.

All floating-point operations here are trusted primitive wrappers. They are useful for runtime math and formatting, but they should not be treated like the SMT-backed integer arithmetic surface.

Import

mo:core/Float

Status

  • Runtime module

Public API

Types

  • Float, Int, Int64, Nat8, Text

Functions

abs(x : Float) : Float

Returns the absolute value.

Use when: code or specifications need this operation with the documented contract.

sqrt(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

ceil(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

floor(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

trunc(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

nearest(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

min(a : Float, b : Float) : Float

Returns the selected bound according to the module's ordering.

Use when: code or specifications need this operation with the documented contract.

max(a : Float, b : Float) : Float

Returns the selected bound according to the module's ordering.

Use when: code or specifications need this operation with the documented contract.

copySign(a : Float, b : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

toInt(x : Float) : Int

Converts between the module type and the target representation.

Use when: crossing between this module's value and another representation.

fromInt(x : Int) : Float

Converts between the module type and the target representation.

Use when: crossing between this module's value and another representation.

toInt64(x : Float) : Int64

Converts between the module type and the target representation.

Use when: crossing between this module's value and another representation.

fromInt64(x : Int64) : Float

Converts between the module type and the target representation.

Use when: crossing between this module's value and another representation.

sin(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

cos(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

tan(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

arcsin(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

arccos(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

arctan(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

arctan2(y : Float, x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

exp(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

log(x : Float) : Float

Computes the corresponding floating-point primitive operation.

Use when: code or specifications need this operation with the documented contract.

toText(x : Float) : Text

Converts between the module type and the target representation.

Use when: crossing between this module's value and another representation.

toFormattedText(x : Float, prec : Nat8, mode : Nat8) : Text

Converts between the module type and the target representation.

Use when: crossing between this module's value and another representation.

Summary

  • Runtime module under mo:core/Float.
  • Exposes 24 public functions.