Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Captain's Log, star date 21:34.5...


devel / comp.lang.tcl / Re: Math precision question

SubjectAuthor
* Math precision questionLuc
`* Math precision questionRich
 `* Math precision questionLuc
  `- Math precision questionArjen Markus

1
Math precision question

<20231115135443.17178bb7@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12793&group=comp.lang.tcl#12793

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Math precision question
Date: Wed, 15 Nov 2023 13:54:43 -0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20231115135443.17178bb7@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="8c9f709df043e9a5ef0fc157f38341bf";
logging-data="1923479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197moqILoKXjYOATOUyGeEJbslIMLm9yJg="
Cancel-Lock: sha1:DVJI13kV38HPLedq5ZeAZPmS4O0=
 by: Luc - Wed, 15 Nov 2023 16:54 UTC

Hi.

$ set ::tcl_precision 2
2 $ expr {1.08688 - 1.08684}
4e-05
$ set ::tcl_precision 17
17
$ expr {1.08688 - 1.08684}
4.0000000000040004e-05

Why don't I just get 0.00004?

--
Luc
>>

Re: Math precision question

<uj33qp$1rs9j$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12794&group=comp.lang.tcl#12794

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Math precision question
Date: Wed, 15 Nov 2023 18:48:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <uj33qp$1rs9j$1@dont-email.me>
References: <20231115135443.17178bb7@lud1.home>
Injection-Date: Wed, 15 Nov 2023 18:48:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f76b345cda51a894c9fb26ac5e56572f";
logging-data="1962291"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GC4HtDe1AkB1TO75elVS1"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:DX5M2luXkOfOkrwGWd2dNtCYQmU=
 by: Rich - Wed, 15 Nov 2023 18:48 UTC

Luc <luc@sep.invalid> wrote:
> Hi.
>
> $ set ::tcl_precision 2

Note this big warning from the documentation:

tcl_precision

This variable controls the number of digits to generate when
converting floating-point values to strings. It defaults to 0.
**Applications should not change this value; it is provided for
compatibility with legacy code.**

> 2
> $ expr {1.08688 - 1.08684}
> 4e-05
> $ set ::tcl_precision 17
> 17
> $ expr {1.08688 - 1.08684}
> 4.0000000000040004e-05
>
> Why don't I just get 0.00004?

https://0.30000000000000004.com/

If you want a particular number of decimal digits when converting to a
string, use [format] and the %f format method.

Re: Math precision question

<20231115222703.4e41649a@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12795&group=comp.lang.tcl#12795

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Math precision question
Date: Wed, 15 Nov 2023 22:27:03 -0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20231115222703.4e41649a@lud1.home>
References: <20231115135443.17178bb7@lud1.home>
<uj33qp$1rs9j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="e64764c1cc4c7a7c6549bd2e73e94b72";
logging-data="2080464"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pfR4qsHkYG7okiJ0vS6HzqUZqcOeZmhk="
Cancel-Lock: sha1:wrhvLvLkirNVqZ0FdOgdbHB+Nko=
 by: Luc - Thu, 16 Nov 2023 01:27 UTC

On Wed, 15 Nov 2023 18:48:57 -0000 (UTC), Rich wrote:

>https://0.30000000000000004.com/
>
>If you want a particular number of decimal digits when converting to a
>string, use [format] and the %f format method.
**************************

Well, I'm glad I asked because I didn't know that site
and it's really interesting.

Thank you again.

--
Luc
>>

Re: Math precision question

<fff654e7-2a84-409d-bd60-65c1128a5f59n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12796&group=comp.lang.tcl#12796

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:2ae8:b0:77b:d8aa:6760 with SMTP id bn40-20020a05620a2ae800b0077bd8aa6760mr17746qkb.2.1700121203272;
Wed, 15 Nov 2023 23:53:23 -0800 (PST)
X-Received: by 2002:a17:903:25ce:b0:1cc:3ac9:717b with SMTP id
jc14-20020a17090325ce00b001cc3ac9717bmr1972394plb.6.1700121202769; Wed, 15
Nov 2023 23:53:22 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 15 Nov 2023 23:53:21 -0800 (PST)
In-Reply-To: <20231115222703.4e41649a@lud1.home>
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.213.134; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.213.134
References: <20231115135443.17178bb7@lud1.home> <uj33qp$1rs9j$1@dont-email.me> <20231115222703.4e41649a@lud1.home>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fff654e7-2a84-409d-bd60-65c1128a5f59n@googlegroups.com>
Subject: Re: Math precision question
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Thu, 16 Nov 2023 07:53:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2119
 by: Arjen Markus - Thu, 16 Nov 2023 07:53 UTC

On Thursday, November 16, 2023 at 2:27:08 AM UTC+1, Luc wrote:
> On Wed, 15 Nov 2023 18:48:57 -0000 (UTC), Rich wrote:
>
> >https://0.30000000000000004.com/
> >
> >If you want a particular number of decimal digits when converting to a
> >string, use [format] and the %f format method.
> **************************
>
> Well, I'm glad I asked because I didn't know that site
> and it's really interesting.
>
> Thank you again.
>
> --
> Luc
> >>
Classic case of floating-point numbers not being decimal numbers. Think of representing 1/3 as a decimal number. That can only be done approximately. The same is true for many fractions that in decimal are finite, when using floating-point numbers, as these use 2 as the base instead of 10.

Regards,

Arjen

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor