google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
6.92k stars 438 forks source link

Fix for #1072: Fix format with general format type. #1073

Closed netomi closed 1 year ago

netomi commented 1 year ago

This PR fixes format when using the general format type and passing a value of 0 like that

jsonnet -e "std.format('%g', [0])"

or

jsonnet -e "'%g' % 0"

It basically adds a safeguard when calculating the exponent for the given value. 0 has to be treated differently as log is not undefined for 0.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.