develooper Front page | perl.perl5.porters | Postings from April 2000

[ID 20000419.005] % does not work as documented for non-integeroperand

From:
Jim Avera
Date:
April 19, 2000 16:20
Subject:
[ID 20000419.005] % does not work as documented for non-integeroperand
Message ID:
200004192320.QAA25975@membrane.ssd.hal.com
This is a bug report for perl from avera@hal.com,
generated with the help of perlbug 1.26 running under perl 5.00502.

-----------------------------------------------------------------
% perl -we 'printf "%f\n", (1.5 % 8)'
1.00000

The documentation says 
  "If $b is positivie, then $a % $b is $a minus the largest multiple 
  of $b that is not greater than $a."

The largest multiple of 8 which is not greater than 1.5 is 0,
so the answer should be 1.5 - 0 = 1.5.

The docs do not say anything about truncating the result to an integer.

Is this a perl bug or a doc bug?

-Jim Avera (jima@hal.com)

-----------------------------------------------------------------

---
Site configuration information for perl 5.00502:

Configured by avera at Mon Jan 18 16:36:45 PST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos membrane 5.5.1 generic_103640-21 sun4u sparc sunw,ultra-5_10 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='/sim/caetools_ssd1/VCS/cctools/sun4-solaris/cc', optimize='-g -O', gccversion=2.7.2.1
    cppflags='-DDEBUGGING'
    ccflags ='-DDEBUGGING'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='/sim/caetools_ssd1/VCS/cctools/sun4-solaris/cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.00502:
    /sim/vcsperl/perl/5.005_02/lib/5.00502/sun4-solaris
    /sim/vcsperl/perl/5.005_02/lib/5.00502
    /sim/vcsperl/perl/5.005_02/lib/site_perl/5.005/sun4-solaris
    /sim/vcsperl/perl/5.005_02/lib/site_perl/5.005
    .

---
Environment for perl 5.00502:
    HOME=/u/avera
    LANG (unset)
    LC_COLLATE=en_US
    LC_CTYPE=en_US
    LC_MESSAGES=C
    LC_MONETARY=en_US
    LC_NUMERIC=en_US
    LC_TIME=en_US
    LD_LIBRARY_PATH=/usr/is/lib:/usr/lib:/usr/openwin/lib:/usr/ucblib
    LOGDIR (unset)
    PATH=/sim/vcsperl/perl/new/bin:/u/avera/bin:/u/avera/bin/misc:/usr/is/bin:/usr/ccs/bin:/usr/is/gnu/bin:/usr/bin:/usr/sbin:/sbin:/opt/SUNWspro-5.1/bin:/usr/ucb:.:/sim/avera/cvshome/bin:/u/avera/bin/hal:/sim/tools/current/bin:/usr/openwin/bin/.:/usr/openwin/bin:/sim/lb/current/bin:/tools/all/qa/current/bin:/tools/all/bin:/u/avera/bin/ssdhosts:/u/avera/bin/ws:/distrib/SunOS__5.6__sun4m/frame-5.5.6/bin
    PERL_BADLANG (unset)
    SHELL=/usr/is/gnu/bin/bash



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About