簡體   English   中英

int() awk 中的 function 更改參數,即使這已經是 integer

[英]int() function in awk changes the argument even if this is integer already

我不明白awk中的以下兩個結果

$ awk 'BEGIN {
  print    (log(.01)/log(10))
  print int(log(.01)/log(10))
}'
-2
-1

版本:

$ awk --version 
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)

不止是眼前一亮:

$ awk 'BEGIN {
  printf "%.16f\n", log(.01)/log(10)
}'
-1.9999999999999996

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM