my $num = log(1_000_000) / log(10);
print "num: $num\n";
print "int(num): " . int($num) . "\n";
print "sprintf(num): " . sprintf("%0.16f", $num) . "\n";
产生:
num: 6
int(num): 5
sprintf(num): 5.9999999999999991
perl打印浮点数的精度是多少?
使用:为 x86_64-linux-thread-multi 构建的 v5.8.8