How can I avoid jq truncating long decimal

爷,独闯天下 提交于 2019-12-24 02:20:03

问题


How can I prevent jq from truncating long decimal values?

For example:

echo '18302628978110292481' | jq .

result: 18302628978110292000


回答1:


Javascript does not support such big numbers and so does jq. The integer size is 2^53. Check this

To make it work, you'll need to treat them as strings:

echo '"18302628978110292481"' | jq .
# Prints "18302628978110292481"


来源:https://stackoverflow.com/questions/27211870/how-can-i-avoid-jq-truncating-long-decimal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!