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

POSIX test #14 on UTS

Thread Next
From:
hom00
Date:
July 10, 2001 08:53
Subject:
POSIX test #14 on UTS
Message ID:
200107101559.IAA28797@cepheus.utsglobal.com
Test 14 in POSIX tests is telling me that 3.14159 != 3.14159.
So OK, perhaps this isn't as impossible as it seems.
Here is the test with some tracing code added:

use     Devel::Peek;            #-- <===
if ($Config{d_strtod}) {
    $lc = &POSIX::setlocale(&POSIX::LC_NUMERIC, 'C') if $Config{d_setlocale};
    ($n, $x) = &POSIX::strtod('3.14159_OR_SO');
# Using long double NVs may introduce greater accuracy than wanted.
    Dump($n);                   #-- <===
    $n =~ s/^3.1415(8999|9000)\d*$/3.14159/
        if $Config{uselongdouble} eq 'define';
    Dump($n);                   #-- <===
    print (($n == 3.14159) && ($x == 6) ?
          "ok 14\n" : "not ok 14 # \$n=$n, \$x=$x\n"); #-- <=== ADDED "#..."
    &POSIX::setlocale(&POSIX::LC_NUMERIC, $lc) if $Config{d_setlocale};
} else { print "# strtod not present\n", "ok 14\n"; }

SV = NV(0x99838) at 0x1845e8
  REFCNT = 1
  FLAGS = (NOK,pNOK)
  NV = 3.14159
SV = NV(0x99838) at 0x1845e8
  REFCNT = 1
  FLAGS = (NOK,pNOK)
  NV = 3.14159
not ok 14 # $n=3.14159, $x=6

OK, I still don't get it.  Anyone know where I should look?

FWIW, I tried this experiment:
juno> perl -e 'printf "%s\n", 3.14159 == "3.14159" ? Eq:Ne'
Eq

Hal Morris,  UTS Global, LLC

Thread Next


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