Native OCaml Rego/OPA policy engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-rego: Value.pp uses %g for huge floats

+6 -2
+6 -2
lib/value.ml
··· 73 73 | Null -> Fmt.string ppf "null" 74 74 | Bool b -> Fmt.bool ppf b 75 75 | Number f -> 76 - if Float.is_integer f && Float.is_finite f then Fmt.pf ppf "%.0f" f 77 - else Fmt.float ppf f 76 + if Float.is_integer f && Float.is_finite f && Float.abs f < 1e16 then 77 + Fmt.pf ppf "%.0f" f 78 + else 79 + (* Go's [%v] for floats prints the shortest round-trippable form; 80 + [%g] is the closest stdlib match. *) 81 + Fmt.pf ppf "%g" f 78 82 | String s -> Fmt.pf ppf "%S" s 79 83 | Array items -> Fmt.pf ppf "[%a]" (Fmt.list ~sep:(Fmt.any ", ") pp) items 80 84 | Set items -> Fmt.pf ppf "{%a}" (Fmt.list ~sep:(Fmt.any ", ") pp) items