package kdl
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Kdl.Num
Source
KDL numbers.
Numeric KDL value.
Although the KDL spec does not differentiate integers and floats, a number is parsed as `Float_raw
(stored as string) if it is written in the e
scientific notation or contains the .
decimal separator. If an integer is too large for the OCaml int
, it is parsed as `Int_raw
instead of `Int
. The strings are not normalized in any way. `Float_raw
also includes special values: "inf"
, "-inf"
, "nan"
.
In general, one should not pattern match over specific constructors of the variant, and instead use the to_*
functions below while matching over #Kdl.number as num
.
Convert the number to float
, potentially losing precision.
Failure
might be raised in case `Int_raw
or `Float_raw
contain an invalid literal, which should not happen if they were constructed by the parsing functions.
Convert the number to int
. Results in None
if `Int_raw
or `Float_raw
are invalid literals or do not fit in int
, or if `Float_raw
is not a whole number. `Float_raw str
is parsed as a float
that must be in the [-(2^53-1), (2^53-1)]
interval.
Convert the number to nativeint
. The to_int
semantics apply.
Unsigned version of the to_nativeint
conversion.