[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000110.002] Perl 5.005_02 math bug



On Mon, Jan 10, 2000 at 01:03:01PM -0700, Tim Jackson wrote:
> On HP PA-RISC systems (perl version 5.005_02 built for PA-RISC1.1), the
> following code
> 
> #!/usr/local/bin/perl5 -w
> 
>   $x = 22818.875 - 22765.65;
>   print("$x\n");
> 
> outputs:
> 
> 53.2249999999985
> 
> The equiv C code
> 
> #include <stdio.h>
> 
> void main(void)
> {
>   double x;
>   x = 22818.875 - 22765.65;
>   printf("%lf\n", x);
> }
> 
> 
> correctly outputs:
> 
> 53.225

Those two code samples are not equivalent.  Try this instead:

  #!/usr/local/bin/perl5 -w

  $x = 22818.875 - 22765.65;
  printf "%lf\n", $x;

Also, refer to the first entry in perlfaq4.

Ronald


References to:
Tim Jackson <thj@hpesthj.fc.hp.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]