Skip Menu |
Report information
Id: 127201
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: dankogai <dankogai [at] dan.co.jp>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: sprintf() float precision cannot go beyond 15[efg]
Download (untitled) / with headers
text/plain 1.4k
This is possibly related to https://rt.perl.org/Ticket/Display.html?id=127184 . Run the code below: #!/usr/bin/env perl6 use v6; my $log2 = log(2); for 0..20 { say sprintf "%%.%dg:\t%.{$_}g", $_, $log2; } and you get: %.0g: 1 %.1g: 0.7 %.2g: 0.69 %.3g: 0.693 %.4g: 0.6931 %.5g: 0.69315 %.6g: 0.693147 %.7g: 0.6931472 %.8g: 0.69314718 %.9g: 0.693147181 %.10g: 0.6931471806 %.11g: 0.69314718056 %.12g: 0.69314718056 %.13g: 0.6931471805599 %.14g: 0.69314718055995 %.15g: 0.693147180559945 %.16g: 0.693147180559945 %.17g: 0.693147180559945 %.18g: 0.693147180559945 %.19g: 0.693147180559945 %.20g: 0.693147180559945 With perl5 version: #!/usr/bin/env perl use v5.22; use warnings; my $log2 = log(2); for (0..20) { say sprintf "%%.%dg:\t%.${_}g", $_, $log2; } %.0g: 0.7 %.1g: 0.7 %.2g: 0.69 %.3g: 0.693 %.4g: 0.6931 %.5g: 0.69315 %.6g: 0.693147 %.7g: 0.6931472 %.8g: 0.69314718 %.9g: 0.693147181 %.10g: 0.6931471806 %.11g: 0.69314718056 %.12g: 0.69314718056 %.13g: 0.6931471805599 %.14g: 0.69314718055995 %.15g: 0.693147180559945 %.16g: 0.6931471805599453 %.17g: 0.69314718055994529 %.18g: 0.693147180559945286 %.19g: 0.6931471805599452862 %.20g: 0.69314718055994528623 Dan the Inaccurate Perl Monger


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org