summaryrefslogtreecommitdiffstats
path: root/otherlibs/num/arith_status.ml
blob: 585db9d01465b08fec04eb50e860d607909d2dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
(***********************************************************************)
(*                                                                     *)
(*                                OCaml                                *)
(*                                                                     *)
(*    Valerie Menissier-Morain, projet Cristal, INRIA Rocquencourt     *)
(*                                                                     *)
(*  Copyright 1996 Institut National de Recherche en Informatique et   *)
(*  en Automatique.  All rights reserved.  This file is distributed    *)
(*  under the terms of the GNU Library General Public License, with    *)
(*  the special exception on linking described in file ../../LICENSE.  *)
(*                                                                     *)
(***********************************************************************)

open Arith_flags;;

let get_error_when_null_denominator () =
  !error_when_null_denominator_flag
and set_error_when_null_denominator choice =
 error_when_null_denominator_flag := choice;;

let get_normalize_ratio () = !normalize_ratio_flag
and set_normalize_ratio choice = normalize_ratio_flag := choice;;

let get_normalize_ratio_when_printing () =
  !normalize_ratio_when_printing_flag
and set_normalize_ratio_when_printing choice =
 normalize_ratio_when_printing_flag := choice;;

let get_floating_precision () = !floating_precision
and set_floating_precision i = floating_precision := i;;

let get_approx_printing () = !approx_printing_flag
and set_approx_printing b = approx_printing_flag := b;;

let arith_print_string s = print_string s; print_string " --> ";;

let arith_print_bool = function
  true -> print_string "ON"
| _ -> print_string "OFF"
;;

let arith_status () =
  print_newline ();

  arith_print_string
  "Normalization during computation";
  arith_print_bool (get_normalize_ratio ());
  print_newline ();
  print_string "     (returned by get_normalize_ratio ())";
  print_newline ();
  print_string "     (modifiable with set_normalize_ratio <your choice>)";
  print_newline ();
  print_newline ();

  arith_print_string
  "Normalization when printing";
  arith_print_bool (get_normalize_ratio_when_printing ());
  print_newline ();
  print_string
  "     (returned by get_normalize_ratio_when_printing ())";
  print_newline ();
  print_string
  "     (modifiable with set_normalize_ratio_when_printing <your choice>)";
  print_newline ();
  print_newline ();

  arith_print_string
  "Floating point approximation when printing rational numbers";
  arith_print_bool (get_approx_printing ());
  print_newline ();
  print_string
  "     (returned by get_approx_printing ())";
  print_newline ();
  print_string
  "     (modifiable with set_approx_printing <your choice>)";
  print_newline ();
  (if (get_approx_printing ())
      then (print_string "  Default precision = ";
            print_int (get_floating_precision ());
            print_newline ();
            print_string "     (returned by get_floating_precision ())";
            print_newline ();
            print_string
              "     (modifiable with set_floating_precision <your choice>)";
            print_newline ();
            print_newline ())
      else print_newline());

  arith_print_string
  "Error when a rational denominator is null";
  arith_print_bool (get_error_when_null_denominator ());
  print_newline ();
  print_string "     (returned by get_error_when_null_denominator ())";
  print_newline ();
  print_string
  "     (modifiable with set_error_when_null_denominator <your choice>)";
  print_newline ()
;;