To what precision does perl print floating-point numbers?
问题 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"; produces: num: 6 int(num): 5 sprintf(num): 5.9999999999999991 To what precision does perl print floating-point numbers? Using: v5.8.8 built for x86_64-linux-thread-multi 回答1: When stringifying floating point numbers, whether to print or otherwise, Perl generally uses the value of DBL_DIG or LDBL_DIG from the float.h or limits.h file where it