2018-01-02 22:02:01 +01:00
|
|
|
type t = float
|
|
|
|
|
|
|
|
let of_float x = x
|
2018-01-02 22:33:17 +01:00
|
|
|
let of_int i = float_of_int i
|
|
|
|
let of_string s = float_of_string s
|
2018-01-02 22:02:01 +01:00
|
|
|
|
|
|
|
let to_float x = x
|
2018-01-02 22:33:17 +01:00
|
|
|
let to_int x = int_of_float x
|
2018-01-02 22:02:01 +01:00
|
|
|
let to_string x =
|
|
|
|
if x >= 0. then
|
|
|
|
Printf.sprintf "+%f" x
|
|
|
|
else
|
|
|
|
Printf.sprintf "%f" x
|
|
|
|
|
2018-03-03 22:13:14 +01:00
|
|
|
let ( + ) a b =
|
|
|
|
(to_float a) +. (to_float b) |> of_float
|
|
|
|
|
|
|
|
let ( - ) a b =
|
|
|
|
(to_float a) -. (to_float b) |> of_float
|
|
|
|
|
|
|
|
let ( * ) a b =
|
|
|
|
(to_float a) *. b |> of_float
|
|
|
|
|
|
|
|
let ( / ) a b =
|
|
|
|
(to_float a) /. b |> of_float
|