Permalink
Browse files

replay trunk@13911: better behavior of printf on nan/infinity floats

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14871 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
1 parent 74b20be commit a9aea4306c39be2fc4460bb45494832bbcad3bdd @gasche gasche committed May 14, 2014
Showing with 5 additions and 2 deletions.
  1. +5 −2 stdlib/camlinternalFormat.ml
@@ -1036,8 +1036,11 @@ let convert_float fconv prec x =
| _ -> is_valid (i + 1)
in
match classify_float x with
- | FP_normal | FP_subnormal | FP_zero when not (is_valid 0) -> str ^ "."
- | FP_infinite | FP_nan | FP_normal | FP_subnormal | FP_zero -> str
+ | FP_normal | FP_subnormal | FP_zero ->
+ if is_valid 0 then str else str ^ "."
+ | FP_infinite ->
+ if x < 0.0 then "neg_infinity" else "infinity"
+ | FP_nan -> "nan"
(* Convert a char to a string according to the OCaml lexical convention. *)
let format_caml_char c =

0 comments on commit a9aea43

Please sign in to comment.