Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?J=c3=b6rg_Buchholz?= Newsgroups: comp.graphics.apps.gnuplot Subject: Re: incorrect arithmetik? Date: Tue, 12 Jan 2016 18:50:29 +0100 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Date: Tue, 12 Jan 2016 17:47:47 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="7854f870a523deebbdd3a1bdabea156f"; logging-data="24905"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jBl9Ji+gDv3aRokKqxdq2hwxHh7r6KIY=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 In-Reply-To: Cancel-Lock: sha1:jNZHLd5SCkAKplfCYbQFy7jeuwI= Xref: csiph.com comp.graphics.apps.gnuplot:3159 On 12.01.2016 14:19, Karl Ratzsch wrote: > Am 12.01.2016 um 11:40 schrieb J=C3=B6rg Buchholz: >> I can not found the solution to the following problem: >> >> b=3D7.2-6.9 >> c=3D8.2-7.9 >> >> show variables > >> b =3D 0.3 >> c =3D 0.299999999999999 >> >> Why is c not 0.3? > > Floating point arithmetics. Most decimal fractions cannot be represente= d > exactly by a binary float variable. > > 8.2 is 1000.00110011.... > 7.2 is 111.11100110011.... > > If the two errors add up in one direction, the result of your > subtraction will be closer to a value that is in fact off by 1 in the > least significant digit. Thanks for the explanation, I think I understand it. J=C3=B6rg