From 6d144445b780d0acdb46b36702b28be17eca1049 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 31 May 2011 07:44:52 -0400 Subject: Proper C pretty-printing of floats in scientific notation --- src/prim.sml | 6 +----- tests/float.ur | 6 ++++++ tests/float.urs | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 tests/float.ur create mode 100644 tests/float.urs diff --git a/src/prim.sml b/src/prim.sml index d4471143..96880487 100644 --- a/src/prim.sml +++ b/src/prim.sml @@ -55,11 +55,7 @@ fun int2s' n = else Int64.toString n -fun float2s n = - if Real64.compare (n, Real64.fromInt 0) = LESS then - "-" ^ Real64.toString (Real64.~ n) - else - Real64.toString n +val float2s = String.translate (fn #"~" => "-" | ch => str ch) o Real64.toString fun toString t = case t of diff --git a/tests/float.ur b/tests/float.ur new file mode 100644 index 00000000..aae6d521 --- /dev/null +++ b/tests/float.ur @@ -0,0 +1,6 @@ +fun main () = + let + val x = 0.001 * 50.0 + in + return {[x]} + end diff --git a/tests/float.urs b/tests/float.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/float.urs @@ -0,0 +1 @@ +val main : unit -> transaction page -- cgit v1.2.3