You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5739 Reporter: smimram Status: closed (set by @xavierleroy on 2015-12-11T18:21:03Z) Resolution: fixed Priority: normal Severity: minor Version: 3.12.1 Target version: 4.01.0+dev Fixed in version: 4.01.0+dev Category: standard library Related to:#4688 Monitored by:@hcarty smimram @damiendoligez
Bug description
When trying to generate code for OCaml (in OCaml) I expected Printf.printf "%F" to generate a float which is a valid expression in OCaml syntax: according to the documentation "%F converts a floating-point argument to Caml syntax". However,
-nan;;
Error: This expression has type float but an expression was expected of type
int
Printf.printf "%F\n" (-.nan);;
-nan
: unit = ()
Maybe should the last expression return "-.nan" (or the syntax could be modified to allow -nan).
Steps to reproduce
Printf.printf "%F\n" (-.nan);;
The text was updated successfully, but these errors were encountered:
printf "%F" neg_infinity also prints "-inf" which suffers from the same problem. I think this was already discussed in #4688.
If I understand correctly the patch of "dra" in #4688, the effect of (printf "%F" (-.nan)) on the Windows platform (mingw or MSVC) could be to return "nan" instead of the negative nan on 4.00 -- I can't test myself, though.
The payload of NaNs include the sign bit. So, a sloppy float->string conversion could test the sign bit, emit a "-" sign, then notice the float is a NaN.
Fixed in 4.01 branch (commit 13910) and in trunk (commit 13911) by special-casing NaN and positive/negative infinity for "%F" conversions.
Original bug ID: 5739
Reporter: smimram
Status: closed (set by @xavierleroy on 2015-12-11T18:21:03Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.1
Target version: 4.01.0+dev
Fixed in version: 4.01.0+dev
Category: standard library
Related to: #4688
Monitored by: @hcarty smimram @damiendoligez
Bug description
When trying to generate code for OCaml (in OCaml) I expected Printf.printf "%F" to generate a float which is a valid expression in OCaml syntax: according to the documentation "%F converts a floating-point argument to Caml syntax". However,
-nan;;
Error: This expression has type float but an expression was expected of type
int
Printf.printf "%F\n" (-.nan);;
-nan
Maybe should the last expression return "-.nan" (or the syntax could be modified to allow -nan).
Steps to reproduce
Printf.printf "%F\n" (-.nan);;
The text was updated successfully, but these errors were encountered: