ripchint
ripchint

Reputation: 35

Is it possible to print a double float

Say i am currently printing a column as a floating point by

awk '{printf "%4.3f \n", $1}'

Is it possible to instead %4.3(some letter/s) to make it a double float?

Upvotes: 1

Views: 106

Answers (1)

Ed Morton
Ed Morton

Reputation: 203995

I suspect she means https://en.wikipedia.org/wiki/Double-precision_floating-point_format. Double precision is what modern (POSIX, etc.) awks use by default to represent a float. When a modern awk prints a float it's using the equivalent of the double-precision C datatype "double" while an ancient awk would be using the equivalent of the single-precision C datatype "float". So I guess the answer to your question is "no", there is no letter/s you can add to the printf spec to change that default which already IS a "double float". See https://www.gnu.org/software/gawk/manual/gawk.html#Arbitrary-Precision-Arithmetic for more info.

If that's NOT what your question is about then edit it to clarify and provide concise, testable sample input and expected output.

Upvotes: 2

Related Questions