Jung
Jung

Reputation: 11

print results with high precision (floating point)

I have 100 columns and 10000 rows, and want to subtract some number only from 4th column.

awk '{$4=$4-0.007797948600925214}{print}' t1 > t2

I tested with $4=0, and the answer is -0.00779795.

How can I use awk to get -0.007797948600925214?

Upvotes: 1

Views: 575

Answers (1)

Juan Diego Godoy Robles
Juan Diego Godoy Robles

Reputation: 14955

Use float formatting , example:

awk 'BEGIN{printf "%.18f", 0.007797948600925214}'

Check the docs.

Upvotes: 1

Related Questions