难道AWK了解E符号写在多少? [英] Does AWK understand number written in in E notation?

查看:337
本文介绍了难道AWK了解E符号写在多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几列,其中一列中包含的格式写入这样的数字制表符分隔文件

I have a tab-separated file with several columns, where one column contains numbers written in a format like this

4.07794484177529E-293

4.07794484177529E-293

不知AWK明白这个符号?即我想只有在该列中的数字是小于0.1的线条。

I wonder if AWK understands this notation? I.e. I want to get only the lines where the numbers in that column are smaller than 0.1.

但我不知道是否AWK会明白4.07794484177529E-293是 - 它可以做这种格式算术比较

But I am not sure if AWK will understand what "4.07794484177529E-293" is - can it do arithmetic comparisons on this format?

推荐答案

是的,回答你的问题, AWK 不明白E符号。

Yes, to answer your question, awk does understand E notation.

您可以确认方式:

awk '{printf "%f\n", $1}' <<< "4.07794484177529E-3"
0.004078

在一般情况下, AWK使用双链precision浮点数重新present所有的数字值。这给了你们之间的范围 1.7E-308 1.7E + 308 的工作,让你有好 4.07794484177529E-293

In general, awk uses double-precision floating-point numbers to represent all numeric values. This gives you the range between 1.7E–308 and 1.7E+308 to work with, so you are okay with 4.07794484177529E-293

另外:你可以指定如何将浮点数的打印使用awk格式如下:

Aside: you can specify how to format the print of floating point number with awk as follows:

awk '{printf "%5.8f\n", $1}' <<< "1.2345678901234556E+4"
12345.67890123

说明:


  • %5.8f 是什么格式的浮动

  • 5 部分指定多少位小数的aPoint
  • 之前打印
  • 8 部分指定多少位数字的小数点后打印

  • %5.8f is what formats the float
  • the 5 part before the . specifies how many digits to print before the decimal apoint
  • the 8 part after the . specifies how many digits to print after the decimal point

这篇关于难道AWK了解E符号写在多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆