develooper Front page | perl.perl5.porters | Postings from August 2001

[ID 20010804.006] inf handling in Perl incomplete

From:
Tels
Date:
August 4, 2001 01:35
Subject:
[ID 20010804.006] inf handling in Perl incomplete
Message ID:
25733_250982900.65894@bugs.perl.org
-----BEGIN PGP SIGNED MESSAGE-----

This is a bug report for perl from perl_dummy@bloodgate.com,
generated with the help of perlbug 1.33 running under perl v5.7.2.

The inf (infinity) handling in Perl is, well, incomplete:

###########################################################################
#!/usr/bin/perl -w

use Test::Simple tests => 12;

my ($x,$y,$z,$u);

$x = inf;                                       # not under use strict!
ok ($x eq 'inf', 'bareword inf');
$x++;
ok ($x eq 'inf', 'inc of bareword inf');        # wrong: 'ing'

my $y = 1e1000000;
ok ($y eq 'inf', 'numerical inf');

my $x = inf;
ok ($x == $y,'$x == $y');
ok ($x eq $y,'$x eq $y');

$y++;
ok ($y eq 'inf','after ++');

$y = - $y;
ok ($y eq '-inf','neg');
$y = - $y;
ok ($y eq 'inf','neg again');

$z = ~$y;
ok ($z eq '-inf','~ +inf');                     # wrong: 0

use integer;

$z = ~$y;
ok ($z eq '-inf','~ +inf under use integer');   # wrong: 0

$z = $y - $y;                                   # +inf - +inf == 0
ok ($z == 0,'+inf - +inf == 0');

$u = -1e10000000;                               # -inf
$z = $y + $u;                                   # +inf + -inf == 0
ok ($z == 0,'+inf + -inf == 0');

###########################################################################

The first part shows that the bareword 'inf' is not considered numerical
inf, but the string 'inf'. Ugh. Also, under use strict this throws an error!
The only way to actually create an inf seems to be to use a really big
number, which might break in further Perl versions, or on different
architectures, when/where these numbers can be handled without creating inf.

Also, negating +inf means -inf-1 (~1 => -2), which should be -inf again.

Bugs are also in v5.6.1. There might be more lurking, I didn't do a fully
inf regression testing.

- ---
Flags:
    category=core
    severity=high
- ---
Site configuration information for perl v5.7.2:

Configured by te at Sat Jul 28 23:19:11 CEST 2001.

Summary of my perl5 (revision 5.0 version 7 subversion 2 patch 11443)
configuration:
  Platform:
    osname=linux, osvers=2.2.16, archname=i686-linux
    uname='linux null 2.2.16 #1 wed aug 2 20:22:26 gmt 2000 i686 unknown '
    config_args='-d -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-Wall -fno-strict-aliasing -I/usr/local/include
- -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-Wall -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    DEVEL11443

- ---
@INC for perl v5.7.2:
    lib
    /usr/local/lib/perl5/5.7.2/i686-linux
    /usr/local/lib/perl5/5.7.2
    /usr/local/lib/perl5/site_perl/5.7.2/i686-linux
    /usr/local/lib/perl5/site_perl/5.7.2
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .

- ---
Environment for perl v5.7.2:
    HOME=/home/te
    LANG=en_US
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games/bin:/usr/games:/
opt/gnome/bin:/opt/kde/bin:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash

- --
perl -MMath::String -e 'print \
Math::String->from_number("215960156869840440586892398248"),"\n"'

 http://bloodgate.com/thief/     Thief - The Dark Project
 http://bloodgate.com/perl       My current Perl projects
 http://freedomforlinks.de       Fight for your right to link.
 PGP key available on http://bloodgate.com/tels.asc or via email.


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1

iQEVAwUBO2uy+HcLPEOTuEwVAQFzIgf/SbfrafE5PzT45OqM4YV9cd9fJ+mlY7DX
wnPgO+5utz7SM2GPzwC7ggD4w/AJmmlnogaWo+AcuPk22Cm5Q4BnYGzgSGc7aC81
l/lkP5Jgsi8fh43wHXuYX4g1tMqDD0TiCa+xMJDAuOVBJ0ftg1abdyPd33wF6DT/
JwvUBFBaS4C+zknmT9Fa/Us+yul69AfYOEwU4JByLZlyM64NfNiqpX1guDe5wi2M
68DVFXES8NaKiejkWC0ZPxam1kQGI4qfduYQsQVg/knH+nsxAVY2VwqhXq1005xQ
OTVbxuTjFx9jMD6PfL1A15oXoa9gRShCOhTVyr829K9SksV0LcS6Bw==
=Flhs
-----END PGP SIGNATURE-----




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