Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exponential to Decimal 1

Status
Not open for further replies.

gixmono

Technical User
Jan 16, 2006
6
MX
Hi Gurus

Mi Name is Raul and I've this little problem with awk.

I'm trying change the data format within an ascii file
from this (floating,exponential or scientific):

#
#
#
0.57210E+06 0.21808E+07 0.10000E+31
0.57210E+06 0.21807E+07 0.10000E+31
0.57210E+06 0.21780E+07 -3736.9
0.57210E+06 0.21779E+07 -3750.0
0.57210E+06 0.21778E+07 -3763.6
0.57210E+06 0.21777E+07 -3779.9
.
.
.

to decimal, using this:

#!/bin/awk -f
NR<3 {
print
}
NR>=3 {
printf "%12.2f %12.2f %12.2f\n", $1, $2, $3
}

But this is what I get:

#
#
#
572100.00 2180800.00 1000000000000000019884624838656.00
572100.00 2180700.00 1000000000000000019884624838656.00
572100.00 2178000.00 -3736.90
572100.00 2177900.00 -3750.00
572100.00 2177800.00 -3763.60
572100.00 2177700.00 -3779.90

It should be:
1000000000000000000000000000000.00

Not:
1000000000000000019884624838656.00

Does anyone knows why ??
 
Hi

The value is not stored with so big precision. Floating point values usually have up to 19 digit precision. For example you get the same in Perl too :
Code:
[blue]master #[/blue] perl -e 'printf "%12.2f",0.10000E+31'
1000000000000000019884624838656.00
The solution could be to use other language, which has such support :
Code:
[blue]master #[/blue] perl -Mbignum -e 'print 0.10000E+31'
10000000000000000000000000000000
Sorry for the offtopic solution.

Feherke.
 
Thank You very much for your help.

I can use perl to do the job.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top