summaryrefslogtreecommitdiff
path: root/caml/Floataux.ml
blob: f61bd5b50a5dc82c11d634a84b1a2675cdc57070 (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
open Camlcoq
open Integers

let singleoffloat f =
  Int32.float_of_bits (Int32.bits_of_float f)

let intoffloat f =
  coqint_of_camlint (Int32.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
  | Ceq -> x = y
  | Cne -> x <> y
  | Clt -> x < y
  | Cle -> x <= y
  | Cgt -> x > y
  | Cge -> x >= y