From 9c2e727d85cb7c0c5a9e0170b1b5bb90f1fbd78f Mon Sep 17 00:00:00 2001 From: Pomin Wu Date: Tue, 7 Jun 2022 11:29:49 +0800 Subject: [PATCH] Add OCaml Zarith example --- _posts/2017-04-30-ocaml.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/_posts/2017-04-30-ocaml.md b/_posts/2017-04-30-ocaml.md index ed0608d..33201b6 100644 --- a/_posts/2017-04-30-ocaml.md +++ b/_posts/2017-04-30-ocaml.md @@ -1,5 +1,14 @@ --- title: OCaml -code: 0.1 +. 0.2;; -result: float = 0.300000000000000044 +code: + - 0.1 +. 0.2;; + - Q.(to_float ((of_ints 1 10) + (of_ints 2 10)));; +result: + - float = 0.300000000000000044 + - float = 0.3 --- + +OCaml has [arbitrary-precision rational number support][1] from the [Zarith library][2]. + +[1]: https://github.com/ocaml/Zarith +[2]: https://opam.ocaml.org/packages/zarith/