Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

No wonder Clairol makes so much money selling shampoo. Lather, Rinse, Repeat is an infinite loop!


devel / comp.lang.python / Re: String to Float, without introducing errors

SubjectAuthor
o Re: String to Float, without introducing errorsPeter J. Holzer

1
Re: String to Float, without introducing errors

<mailman.1212.1671313514.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25156&group=comp.lang.python#25156

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-python@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: String to Float, without introducing errors
Date: Sat, 17 Dec 2022 22:45:12 +0100
Lines: 48
Message-ID: <mailman.1212.1671313514.20444.python-list@python.org>
References: <5BF45E45-9112-4680-9692-15AE936A56A3@paulstgeorge.com>
<512a2101-ea59-29aa-753a-eafe0655fc32@yahoo.co.uk>
<2C24114F-7CA3-4AE0-B76F-988B33517F93@paulstgeorge.com>
<20221217214512.wlm2htukxisij6v5@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="u5xjenl7npr2urei"
X-Trace: news.uni-berlin.de FXnH4FPFdonC6caqTwSqnArYBtbu8ZrFeiHmzAOPm1ow==
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'content-
type:multipart/signed': 0.05; 'string': 0.07; 'subject:without':
0.07; 'content-type:application/pgp-signature': 0.09;
'filename:fname piece:asc': 0.09; 'filename:fname
piece:signature': 0.09; 'filename:fname:signature.asc': 0.09;
'"creative': 0.16; '__/': 0.16; 'challenge!"': 0.16; 'decimal':
0.16; 'from:addr:hjp-python': 0.16; 'from:addr:hjp.at': 0.16;
'from:name:peter j. holzer': 0.16; 'hjp@hjp.at': 0.16; 'holzer':
0.16; 'reality.': 0.16; 'solved': 0.16; 'stross,': 0.16;
'truncate': 0.16; 'url-ip:212.17.106.137/32': 0.16; 'url-
ip:212.17.106/24': 0.16; 'url-ip:212.17/16': 0.16; 'url:hjp':
0.16; '|_|_)': 0.16; 'wrote:': 0.16; 'instead': 0.17; 'to:addr
:python-list': 0.20; 'fact': 0.28; 'sense': 0.28; 'error': 0.29;
'(as': 0.32; "wouldn't": 0.32; 'header:In-Reply-To:1': 0.34;
'single': 0.39; 'use': 0.39; 'something': 0.40; 'george': 0.62;
'received:212': 0.62; 'number,': 0.64; 'received:userid': 0.66;
'time.': 0.66; 'url-ip:212/8': 0.69; 'paul': 0.81; 'characters':
0.84; 'received:at': 0.84; 'subject:introducing': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <2C24114F-7CA3-4AE0-B76F-988B33517F93@paulstgeorge.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20221217214512.wlm2htukxisij6v5@hjp.at>
X-Mailman-Original-References: <5BF45E45-9112-4680-9692-15AE936A56A3@paulstgeorge.com>
<512a2101-ea59-29aa-753a-eafe0655fc32@yahoo.co.uk>
<2C24114F-7CA3-4AE0-B76F-988B33517F93@paulstgeorge.com>
 by: Peter J. Holzer - Sat, 17 Dec 2022 21:45 UTC
Attachments: signature.asc (application/pgp-signature)

On 2022-12-17 21:45:06 +0100, Paul St George wrote:
> It was the rounding rounding error that I needed to avoid (as Peter J.
> Holzer suggested). The use of decimal solved it and just in time. I
> was about to truncate the number, get each of the characters from the
> string mantissa, and then do something like this:
>
> 64550.727
>
> 64550 + (7 * 0.1) + (2 * 0.01) + (7 * 0.001)

That wouldn't have helped. In fact it would have made matters worse
because instead of a single rounding operation you now have nine!

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)

devel / comp.lang.python / Re: String to Float, without introducing errors

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor