package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A Format.t tells Percent.format how to render a floating-point value as a string, like a printf conversion specification.

For example:

format (Format.exponent ~precision) = sprintf "%.e" precision

The _E naming suffix in Format values is mnenomic of a capital E (rather than e) being used in floating-point exponent notation.

Here is the documentation of the floating-point conversion specifications from the OCaml manual:

  • f: convert a floating-point argument to decimal notation, in the style dddd.ddd.
  • F: convert a floating-point argument to OCaml syntax (dddd. or dddd.ddd or d.ddd e+-dd).
  • e or E: convert a floating-point argument to decimal notation, in the style d.ddd e+-dd (mantissa and exponent).
  • g or G: convert a floating-point argument to decimal notation, in style f or e, E (whichever is more compact).
  • h or H: convert a floating-point argument to hexadecimal notation, in the style 0xh.hhhh e+-dd (hexadecimal mantissa, exponent in decimal and denotes a power of 2).
type t
val sexp_of_t : t -> Sexplib0.Sexp.t
val exponent : precision:Base.Int.t -> t

sprintf "%.*e" precision

val exponent_E : precision:Base.Int.t -> t

sprintf "%.*E" precision

val decimal : precision:Base.Int.t -> t

sprintf "%.*f" precision

val ocaml : t

sprintf "%F"

val compact : precision:Base.Int.t -> t

sprintf "%.*g" precision

val compact_E : precision:Base.Int.t -> t

sprintf "%.*G" precision

val hex : precision:Base.Int.t -> t

sprintf "%.*h" precision

val hex_E : precision:Base.Int.t -> t

sprintf "%.*H" precision

OCaml

Innovation. Community. Security.