Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Clarify description of sprintf "%.1g" in perlfunc #15313

Closed
p5pRT opened this issue May 9, 2016 · 7 comments
Closed

[PATCH] Clarify description of sprintf "%.1g" in perlfunc #15313

p5pRT opened this issue May 9, 2016 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented May 9, 2016

Migrated from rt.perl.org#128105 (status was 'resolved')

Searchable as RT128105$

@p5pRT
Copy link
Author

p5pRT commented May 9, 2016

From maxwellhaydn@gmail.com

Created by maxwellhaydn@gmail.com

Description of sprintf "%.1g" in perlfunc is unclear. This sets
the number of *significant* digits, not the maximum number of digits,
period. Clarified the wording and added more examples.

Perl Info

Flags:
    category=docs
    severity=low
    Type=Patch
    PatchStatus=HasPatch

Site configuration information for perl 5.25.1:

Configured by mcarey at Mon May  9 15:13:59 MDT 2016.

Summary of my perl5 (revision 5 version 25 subversion 1) configuration:
  Commit id: d35fca5f9e7ec48bb82d2a2d4566dfb68f955e6e
  Platform:
    osname=linux, osvers=4.4.0, archname=x86_64-linux
    uname='linux mcmes21.cgd.ucar.edu 4.4.0 #1 smp thu jan 21 15:28:04 mst 2016 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dusedevel'
    hint=previous, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='4.8.5 20150623 (Red Hat 4.8.5-4)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64 /usr/local/lib /usr/lib
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.17.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.17'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.25.1:
    lib
    /usr/local/lib/perl5/site_perl/5.25.1/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.25.1
    /usr/local/lib/perl5/5.25.1/x86_64-linux
    /usr/local/lib/perl5/5.25.1
    .


Environment for perl 5.25.1:
    HOME=/home/mcarey
    LANG=en_US.ISO-8859-1
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/mcarey/perl5/perlbrew/bin:/home/mcarey/perl5/perlbrew/perls/perl-5.16.3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/mcarey/.local/bin:/home/mcarey/bin:/home/mcarey/.local/bin:/home/mcarey/bin:/home/mcarey/.local/bin:/home/mcarey/bin:/home/mcarey/nmap-7.12/bin
    PERLBREW_BASHRC_VERSION=0.73
    PERLBREW_HOME=/home/mcarey/.perlbrew
    PERLBREW_MANPATH=/home/mcarey/perl5/perlbrew/perls/perl-5.16.3/man
    PERLBREW_PATH=/home/mcarey/perl5/perlbrew/bin:/home/mcarey/perl5/perlbrew/perls/perl-5.16.3/bin
    PERLBREW_PERL=perl-5.16.3
    PERLBREW_ROOT=/home/mcarey/perl5/perlbrew
    PERLBREW_VERSION=0.73
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented May 9, 2016

From maxwellhaydn@gmail.com

0001-Clarify-description-of-sprintf-.1g.patch
From f1451f94ba642fcea98a383f9a796ab2c7c5265f Mon Sep 17 00:00:00 2001
From: Maxwell Carey <maxwellhaydn@gmail.com>
Date: Mon, 9 May 2016 15:33:41 -0600
Subject: [PATCH] Clarify description of sprintf "%.1g"

sprintf "%.1g" sets the number of *significant* digits, not the
maximum number of digits to show. Added examples for values less
than 1.
---
 pod/perlfunc.pod | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index e9c7038..5c778f1 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -7745,9 +7745,8 @@ For example:
   printf '<%e>', 10;   # prints "<1.000000e+01>"
   printf '<%.1e>', 10; # prints "<1.0e+01>"
 
-For "g" and "G", this specifies the maximum number of digits to show,
-including those prior to the decimal point and those after it; for
-example:
+For "g" and "G", this specifies the maximum number of significant digits to
+show; for example:
 
   # These examples are subject to system-specific variation.
   printf '<%g>', 1;        # prints "<1>"
@@ -7757,6 +7756,9 @@ example:
   printf '<%.2g>', 100.01; # prints "<1e+02>"
   printf '<%.5g>', 100.01; # prints "<100.01>"
   printf '<%.4g>', 100.01; # prints "<100>"
+  printf '<%.1g>', 0.0111; # prints "<0.01>"
+  printf '<%.2g>', 0.0111; # prints "<0.011>"
+  printf '<%.3g>', 0.0111; # prints "<0.0111>"
 
 For integer conversions, specifying a precision implies that the
 output of the number itself should be zero-padded to this width,
-- 
1.8.3.1

@p5pRT
Copy link
Author

p5pRT commented May 16, 2016

From @tonycoz

On Mon May 09 14​:57​:49 2016, maxwellhaydn@​gmail.com wrote​:

Description of sprintf "%.1g" in perlfunc is unclear. This sets
the number of *significant* digits, not the maximum number of digits,
period. Clarified the wording and added more examples.

Thanks, applied as 0533ae6.

Add you to AUTHORS in bfea061.

Tony

@p5pRT
Copy link
Author

p5pRT commented May 16, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 16, 2016

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant