Numbers.Protocols.ToFloat protocol (numbers v5.2.5)

Copy Markdown

For supporting Numbers.to_float/1.

Summary

Types

t()

All the types that implement this protocol.

Functions

Convert the custom Numeric struct to the built-in float datatype.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

to_float(num)

@spec to_float(t()) :: {:ok, t_as_float :: float()} | :error

Convert the custom Numeric struct to the built-in float datatype.

It is okay to lose precision during this conversion.