From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Mon, 17 Nov 2008 12:34:04 +0000 (+0000) Subject: Added two float tests which show a difference under native & cross compilers. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=73693beee1c7e4045438632f0a36f8268f729c0f;p=fedora-mingw.git Added two float tests which show a difference under native & cross compilers. --- diff --git a/.hgignore b/.hgignore index 745fc89..a9420f6 100644 --- a/.hgignore +++ b/.hgignore @@ -79,6 +79,8 @@ ocaml/test_format ocaml/sudoku ocaml/test_buffer ocaml/test_overflow +ocaml/test_float +ocaml/test_float2 ocaml/*.exe ocaml/*.cmi ocaml/*.cmx diff --git a/ocaml/Makefile b/ocaml/Makefile index 3a2972d..fe653ef 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -3,7 +3,8 @@ all: test1 test1.exe test2 test2.exe test3 test3.exe test4 test4.exe \ test_format test_format.exe sudoku sudoku.exe \ - test_buffer test_buffer.exe test_overflow test_overflow.exe + test_buffer test_buffer.exe test_overflow test_overflow.exe \ + test_float test_float.exe test_float2 test_float2.exe test1: test1.ml ocamlopt $< -o $@ @@ -53,6 +54,19 @@ test_overflow: test_overflow.ml test_overflow.exe: test_overflow.ml i686-pc-mingw32-ocamlopt $< -o $@ +test_float: test_float.ml + ocamlopt $< -o $@ + +test_float.exe: test_float.ml + i686-pc-mingw32-ocamlopt $< -o $@ + +test_float2: test_float2.ml + ocamlopt $< -o $@ + +test_float2.exe: test_float2.ml + i686-pc-mingw32-ocamlopt $< -o $@ + clean: rm -f test[1-4] test_format sudoku test_buffer test_overflow \ + test_float test_float2 \ *.exe *.cmi *.cmx *.o diff --git a/ocaml/test_float.ml b/ocaml/test_float.ml new file mode 100644 index 0000000..04aff8b --- /dev/null +++ b/ocaml/test_float.ml @@ -0,0 +1,14 @@ +(* Float test, part of calendar test which was failing. *) + +open Printf + +let x = 1 * 3600 + 2 * 60 + 3 ;; + +printf "minutes = %g\n" (float x /. 60.) ;; + +printf "minutes (immediate) = 62.05 is %b\n" ((float x /. 60.) = 62.05) ;; + +let m = float x /. 60. ;; + +printf "minutes (variable) = 62.05 is %b\n" (m = 62.05) ;; + diff --git a/ocaml/test_float2.ml b/ocaml/test_float2.ml new file mode 100644 index 0000000..a958984 --- /dev/null +++ b/ocaml/test_float2.ml @@ -0,0 +1,7 @@ +(* Another float/int conversion problem or difference. *) + +open Printf ;; + +printf "%d\n" (int_of_float (62.05 *. 60.)) ;; +let s = 62.05 *. 60. ;; +printf "%d\n" (int_of_float s) ;;