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

Perl assumes "inf*" == "Infinity" == number #255

Closed
p5pRT opened this issue Jul 27, 1999 · 3 comments
Closed

Perl assumes "inf*" == "Infinity" == number #255

p5pRT opened this issue Jul 27, 1999 · 3 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jul 27, 1999

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

Searchable as RT1072$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 27, 1999

From goldin@cs.columbia.edu

#! /usr/bin/perl

# In "Is It a Number?" (http​://www.perl.com/CPAN/doc/FMTEYEWTK/is_numeric.html),
# Tom Christiansen sez that $word += 0 will tell if $word is numeric. It
# does not, because Perl assumes that any word starting with the letters "inf"
# corresponds to the notion of "Infinity," which makes it think that it can
# legally perform the addition in $word += 0. There should probably be some
# magic that is smarter about distinguishing "inf*" words from Infinity,
# and/or the FMTEYEWTK should be corrected to account for this phenomenon.
#
# -Ilya Goldin (igoldin@​capaccess.org)
# P.S. As one would expect, adding 0 to "nan" also produces unwanted results.

print "Enter any word. Words starting with \"inf\" will produce the error.\n";
$foo = <>;

$iFoo = $foo + 0;
if ($iFoo == 0)
{
  print "$iFoo​: 0\n";
}
else
{
  print "$iFoo​: 1\n";
}
 


Site configuration information for perl 5.00502​:

Configured by ib42 at Fri Nov 20 17​:52​:24 EST 1998.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration​:
  Platform​:
  osname=solaris, osvers=2.6, archname=sun4-solaris
  uname='sunos joy.cs.columbia.edu 5.6 generic_105181-07 sun4u sparc '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='gcc -B/usr/ccs/bin/ -B/usr/ccs/bin/', optimize='-O2', gccversion=egcs-2.91.57 19980901 (egcs-1.1 release)
  cppflags='-I/usr/local/gnu/include -I/usr/local/include'
  ccflags ='-I/usr/local/gnu/include -I/usr/local/include'
  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='gcc -B/usr/ccs/bin/ -B/usr/ccs/bin/', ldflags ='-L/usr/local/gnu/lib -R/usr/local/gnu/lib -L/usr/local/lib -R/usr/local/lib'
  libpth=/usr/local/gnu/lib /usr/local/lib /lib /usr/lib /usr/ccs/lib
  libs=-lsocket -lnsl -lgdbm -ldb -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/gnu/lib -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl 5.00502​:
  /u/visit/goldin/perl/Tree-DAG_Node-1.01
  /usr/local/perl5/lib/5.00502/sun4-solaris
  /usr/local/perl5/lib/5.00502
  /usr/local/perl5/lib/site_perl/5.005/sun4-solaris
  /usr/local/perl5/lib/site_perl/5.005
  .


Environment for perl 5.00502​:
  HOME=/u/visit/goldin
  LANG (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/ccs/bin​:/usr/local/gnu/bin​:/usr/local/bin​:/opt/CUCStex/bin​:/opt/CUCSX11R6/bin​:/usr/bin​:/usr/local/bin​:/usr/local/gnu/bin​:/usr/openwin/bin​:/usr/local/X11/bin​:/usr/local/unsupported/bin​:/usr/ucb​:/usr/sbin​::/usr/ccs/bin​:/usr/local/pub/bin​:/proj/nlp/tools/dot/dot/bin​:/opt/CUCSmisc/bin​:/opt/CUCSgnu/bin​:/opt/CUCSperl5/bin
  PERLLIB=/u/visit/goldin/perl/Tree-DAG_Node-1.01
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 28, 1999

From @jhi

Thanks for your report. This particular problem has been reported in
various incarnations already earlier. The difficulty in fixing this
is that there is a multitude of Inf/NaN behaviors over the large set
of platforms Perl runs on. Currently Perl just basically does what
the platform tells it to do, via atof() and similar library calls.
In summary​: we know of the problem but we don't have a clear plan
what to do.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Jul 28, 1999

From @jhi

Ilya Goldin writes​:

Thank you for the explanation. It seems that this bug should be publicly
documented, at the very least.

If the problem of the Inf/NaN issue is the conversion from "inf*" into
Infinity, would it possibly make sense to make the conversion a little
stricter, so that only "Infinity" gets converted into Infinity?

It gets messy because Perl does nothing and knows nothing about any "inf".
It just hands the system libraries a string and accepts what the libraries
give back. Adding code to Perl to pre-inspect the string would make things
more regular but also slower.

Also, is anyone actively investigating this problem, or is this just a
known issue with a low priority?

Sadly the second one.

-Ilya

Jarkko Hietaniemi wrote​:

Thanks for your report. This particular problem has been reported in
various incarnations already earlier. The difficulty in fixing this
is that there is a multitude of Inf/NaN behaviors over the large set
of platforms Perl runs on. Currently Perl just basically does what
the platform tells it to do, via atof() and similar library calls.
In summary​: we know of the problem but we don't have a clear plan
what to do.

--
$jhi++; # http​://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.