mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
feat(float): add of_string_opt
This commit is contained in:
parent
5143e28ce8
commit
1dcc529623
2 changed files with 6 additions and 0 deletions
|
|
@ -112,6 +112,9 @@ let of_int (a:int) = Stdlib.float_of_int a
|
||||||
let to_string (a:float) = Stdlib.string_of_float a
|
let to_string (a:float) = Stdlib.string_of_float a
|
||||||
let of_string_exn (a:string) = Stdlib.float_of_string a
|
let of_string_exn (a:string) = Stdlib.float_of_string a
|
||||||
let of_string (a:string) = Stdlib.float_of_string a
|
let of_string (a:string) = Stdlib.float_of_string a
|
||||||
|
let of_string_opt (a:string) =
|
||||||
|
try Some (Stdlib.float_of_string a)
|
||||||
|
with _ -> None
|
||||||
|
|
||||||
|
|
||||||
let random n st = Random.State.float st n
|
let random n st = Random.State.float st n
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,9 @@ val of_string : string -> t
|
||||||
@raise Failure in case of failure. *)
|
@raise Failure in case of failure. *)
|
||||||
[@@ocaml.deprecated "use of_string_exn instead"]
|
[@@ocaml.deprecated "use of_string_exn instead"]
|
||||||
|
|
||||||
|
val of_string_opt : string -> t option
|
||||||
|
(** @since NEXT_RELEASE *)
|
||||||
|
|
||||||
val equal_precision : epsilon:t -> t -> t -> bool
|
val equal_precision : epsilon:t -> t -> t -> bool
|
||||||
(** Equality with allowed error up to a non negative epsilon value. *)
|
(** Equality with allowed error up to a non negative epsilon value. *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue