summaryrefslogtreecommitdiff
path: root/stdlib/printf.ml
diff options
context:
space:
mode:
authorLuc Maranget <luc.maranget@inria.fr>2014-03-13 15:03:16 +0000
committerLuc Maranget <luc.maranget@inria.fr>2014-03-13 15:03:16 +0000
commit1338d73c180d22cd2fd2abc5b46554a56f66b1f5 (patch)
tree1d7171e373a49abdbac5bc790f896aadbca27718 /stdlib/printf.ml
parent18e6a3781be059367bfff403aa8a41e9dc200844 (diff)
downloadocaml-jo401.tar.gz
Merge jo401 w.r.t ocaml/4.01 from 13776 to 14115jo401
Plus ld.conf changes git-svn-id: http://caml.inria.fr/svn/ocaml/branches/jo401@14458 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/printf.ml')
-rw-r--r--stdlib/printf.ml16
1 files changed, 11 insertions, 5 deletions
diff --git a/stdlib/printf.ml b/stdlib/printf.ml
index 2fa14bbfc6..3801692047 100644
--- a/stdlib/printf.ml
+++ b/stdlib/printf.ml
@@ -454,10 +454,13 @@ let format_float_lexeme =
valid_float_loop 0 in
(fun sfmt x ->
- let s = format_float sfmt x in
match classify_float x with
- | FP_normal | FP_subnormal | FP_zero -> make_valid_float_lexeme s
- | FP_nan | FP_infinite -> s)
+ | FP_normal | FP_subnormal | FP_zero ->
+ make_valid_float_lexeme (format_float sfmt x)
+ | FP_infinite ->
+ if x < 0.0 then "neg_infinity" else "infinity"
+ | FP_nan ->
+ "nan")
;;
(* Decode a format string and act on it.
@@ -540,8 +543,11 @@ let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m =
| 'F' as conv ->
let (x : float) = get_arg spec n in
let s =
- if widths = [] then Pervasives.string_of_float x else
- format_float_lexeme (extract_format_float conv fmt pos i widths) x in
+ format_float_lexeme
+ (if widths = []
+ then "%.12g"
+ else extract_format_float conv fmt pos i widths)
+ x in
cont_s (next_index spec n) s (succ i)
| 'B' | 'b' ->
let (x : bool) = get_arg spec n in