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

Re: Report /pro/3gl/CPAN/perl-5.7.1

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
June 27, 2001 14:18
Subject:
Re: Report /pro/3gl/CPAN/perl-5.7.1
Message ID:
20010627221833.G59620@plum.flirble.org
On Wed, Jun 27, 2001 at 04:24:01PM +0100, Mike Guy wrote:
> Nicholas Clark <nick@ccl4.org> wrote
> > On Mon, Jun 25, 2001 at 05:27:44PM -0500, Jarkko Hietaniemi wrote:
> > >   NV = 4745162525730
> > >   NV = 4745162525730
> >
> > This is crazy. They appear to be the same.
> 
> Not necessarily.    Sneaky stuff, float-to-string conversion.   Watch:

> If you want to know reliably the value of an NV, you have to look at more
> that its printed form.    If you know a quantity which is near to the
> expected value, and which is exactly representable, the simplest
> trick is to display the difference from that quantity, e.g.
> displaying  $y-4745162525730  in the above example.

Good point. What does the nasty AIX configuration make of:

#!/usr/bin/perl -w
$x = 4745162525730;
$y = int(279964589018079/59);
if ($y == $x) {
  print "ok 13\n"
} else {
  print "not ok 13 # int(279964589018079/59) is $y, not $x\n";
}
use Devel::Peek;
Dump($x);
Dump($y);
Dump($y-4745162525730);

#!/usr/bin/perl -w
$x = 4745162525730;
$y = int(279964589018079/59);
if ($x == $y) {
  print "ok 13\n"
} else {
  print "not ok 13 # int(279964589018079/59) is $y, not $x\n";
}
use Devel::Peek;
Dump($x);
Dump($y);
Dump($y-4745162525730);


I get 0 for the last dumps

Nicholas Clark

Thread Previous | 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