blob: ebea88414abc39ea0b670583345927b3ea573475 (
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
|
(* *********************************************************************)
(* *)
(* The Compcert verified compiler *)
(* *)
(* Xavier Leroy, INRIA Paris-Rocquencourt *)
(* *)
(* Copyright Institut National de Recherche en Informatique et en *)
(* Automatique. All rights reserved. This file is distributed *)
(* under the terms of the INRIA Non-Commercial License Agreement. *)
(* *)
(* *********************************************************************)
open Camlcoq
let singleoffloat f =
Int32.float_of_bits (Int32.bits_of_float f)
let intoffloat f =
coqint_of_camlint (Int32.of_float f)
let intuoffloat f =
coqint_of_camlint (Int64.to_int32 (Int64.of_float f))
let floatofint i =
Int32.to_float (camlint_of_coqint i)
let floatofintu i =
Int64.to_float (Int64.logand (Int64.of_int32 (camlint_of_coqint i))
0xFFFFFFFFL)
let cmp c (x: float) (y: float) =
match c with
| Integers.Ceq -> x = y
| Integers.Cne -> x <> y
| Integers.Clt -> x < y
| Integers.Cle -> x <= y
| Integers.Cgt -> x > y
| Integers.Cge -> x >= y
let bits_of_single f = coqint_of_camlint (Int32.bits_of_float f)
let single_of_bits f = Int32.float_of_bits (camlint_of_coqint f)
let bits_of_double f = coqint_of_camlint64 (Int64.bits_of_float f)
let double_of_bits f = Int64.float_of_bits (camlint64_of_coqint f)
|