Your message dated Wed, 09 Feb 2005 20:39:36 +0100
with message-id <[EMAIL PROTECTED]>
and subject line Bug#294386: Arithetical bug in perl?
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 9 Feb 2005 14:23:45 +0000
>From [EMAIL PROTECTED] Wed Feb 09 06:23:45 2005
Return-path: <[EMAIL PROTECTED]>
Received: from (hermes.interblock.pl) [80.51.141.226] (postfix)
        by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
        id 1Cyskq-0005Dq-00; Wed, 09 Feb 2005 06:23:44 -0800
Received: from localhost (localhost [127.0.0.1])
        by hermes.interblock.pl (Postfix) with ESMTP id 80295AAFED
        for <[EMAIL PROTECTED]>; Wed,  9 Feb 2005 15:23:23 +0100 (CET)
Received: from hermes.interblock.pl ([127.0.0.1])
        by localhost (hermes [127.0.0.1]) (amavisd-new, port 10024)
        with ESMTP id 30833-04 for <[EMAIL PROTECTED]>;
        Wed, 9 Feb 2005 15:23:17 +0100 (CET)
Received: from poczta.interblock.pl (localhost [127.0.0.1])
        by hermes.interblock.pl (Postfix) with ESMTP id 19962AAFE4
        for <[EMAIL PROTECTED]>; Wed,  9 Feb 2005 15:23:16 +0100 (CET)
From: "Rafal Ramocki" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Arithetical bug in perl?
Date: Wed, 9 Feb 2005 17:53:16 +0330
Message-Id: <[EMAIL PROTECTED]>
X-Mailer: Open WebMail 2.41 20040926
X-OriginatingIP: 149.156.124.3 (maniac)
MIME-Version: 1.0
Content-Type: text/plain;
        charset=iso-8859-2
X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at interblock.pl
Delivered-To: [EMAIL PROTECTED]
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
        (1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
        autolearn=no version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 

Package: perl
Version: 5.6.1-8.8, v5.8.4-5

I was writing a small script, but happened something wired.
This is my script:
-----
#!/usr/bin/perl

my $z1=1;
my $z2=1;

while ($z2 < 3 )
{
    $z1 = $z1 + 0.01;
    if ($z1 > 7.11)
    {
        $z1 = 0.01;
        $z2 = $z2 + 0.01;
        print "z2= $z2\n";
    }

}
-----
after I ran it i saw on the console folowing output (fragment)
<cut>
z2= 2.23
z2= 2.24
z2= 2.25
z2= 2.26
z2= 2.27
z2= 2.27999999999999
z2= 2.28999999999999
z2= 2.29999999999999
z2= 2.30999999999999
<cut>
z2= 2.70999999999999
z2= 2.71999999999999
z2= 2.72999999999999
z2= 2.73999999999999
z2= 2.74999999999998
z2= 2.75999999999998
z2= 2.76999999999998
z2= 2.77999999999998
<cut>

I have wondering about that for some time. I don't have idea what is 
happening and way. In the middle of operation from z2 is substractet that 
verry small value 0.00000000000001 or added 0.00999999999999 insteed of 0.01. 
and I dont know why.

I've tested that script on 3 folowing machines:
Debian stable
Kernel 2.4.27
libc6 2.2.5-11.8
zeus:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 5
model name      : Pentium II (Deschutes)
stepping        : 2
cpu MHz         : 233.866
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 mmx fxsr
bogomips        : 466.94

Debian Testing:
libc6 2.3.2.ds1-20
kernel 2.4.28

cerber:/home/interblock/maniac# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 2
model name      : Intel(R) Celeron(R) CPU 2.00GHz
stepping        : 9
cpu MHz         : 1995.042
cache size      : 128 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips        : 3984.58

Debian Testing
libc6 2.3.2.ds1-20
kernel 2.4.29
hermes:/home/staff/maniac# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 8
model name      : Celeron (Coppermine)
stepping        : 3
cpu MHz         : 567.975
cache size      : 128 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov 
pat pse36 mmx fxsr sse
bogomips        : 1130.49

If i can give you any other help please ask.


---------------------------------------
Received: (at 294386-done) by bugs.debian.org; 9 Feb 2005 19:39:42 +0000
>From [EMAIL PROTECTED] Wed Feb 09 11:39:42 2005
Return-path: <[EMAIL PROTECTED]>
Received: from mail.enyo.de [212.9.189.167] 
        by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
        id 1Cyxgc-0005Al-00; Wed, 09 Feb 2005 11:39:42 -0800
Received: from deneb.enyo.de ([212.9.189.171])
        by albireo.enyo.de with esmtp id 1CyxgY-0003M7-3J; Wed, 09 Feb 2005 
20:39:38 +0100
Received: from fw by deneb.enyo.de with local (Exim 4.43)
        id 1CyxgW-0007Nn-3e; Wed, 09 Feb 2005 20:39:36 +0100
From: Florian Weimer <[EMAIL PROTECTED]>
To: "Rafal Ramocki" <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Subject: Re: Bug#294386: Arithetical bug in perl?
References: <[EMAIL PROTECTED]>
Date: Wed, 09 Feb 2005 20:39:36 +0100
In-Reply-To: <[EMAIL PROTECTED]> (Rafal Ramocki's message of
        "Wed, 9 Feb 2005 17:53:16 +0330")
Message-ID: <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Delivered-To: [EMAIL PROTECTED]
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
        (1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER 
        autolearn=no version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 

* Rafal Ramocki:

> I was writing a small script, but happened something wired.

This is not a bug, this is how floating point arithmetic works.  In
binary floating point arithmetic, 0.01 has no exact representation
(like one third in decimal floating point).  The errors pile up, and
after a few iterations of your loop, they become apparent.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to