ocaml-batteries-team / batteries-included

Batteries Included project
http://ocaml-batteries-team.github.com/batteries-included/hdoc2/
Other
517 stars 106 forks source link

BatPrintf does not support `%h` conversion #961

Open rixed opened 4 years ago

rixed commented 4 years ago

One has to resort to Legacy.Printf.sprintf for that, which is not convenient. Also, this crash at runtime!

UnixJunkie commented 4 years ago

If this is supported by the stdlib, how can batteries not support it? I have never since this specifier though.

UnixJunkie commented 4 years ago
h or H: convert a floating-point argument to hexadecimal notation, in the style 0xh.hhhh p+-dd (hexadecimal mantissa, exponent in decimal and denotes a power of 2).
UnixJunkie commented 4 years ago
utop # Printf.printf "%h\n" 1.0;;
0x1p+0
utop # #require "batteries";;
utop # BatPrintf.printf "%h\n" 1.0;;
Exception:
Invalid_argument
 "printf: bad conversion %h, at char number 1 in format string ``%h\n''".
UnixJunkie commented 4 years ago

I discover that batteries has a reimplementation of the Printf module. Since it uses BatInnerIO, I suspect it is slower than Stdlib.Printf. And I suspect that's why I never used this batteries module...