Quantcast
Channel: Convert floating point numbers to decimal numbers - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 5

Answer by user79743 for Convert floating point numbers to decimal numbers

$
0
0

This will do the conversion:

awk '{print $1, $2, $3 * 10**$4}' file.csv

Assuming:

  1. There is an space bettween the e and the actual exponent.
  2. The exponent is the last field of each line.

If an specific format is needed, some form of printf could be used.

For example:

awk '{printf( "%s %s %g "ORS,$1,$2,$3*10**$4)}' file.csv

could print this:

1 1 1423 
1 2 1589 
1 3 85000 
1 4 8900 
1 5 8796 
2 8 2.589e+28

Last line added to show final format for big exponents.


Viewing all articles
Browse latest Browse all 5

Trending Articles