Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Unix is a Registered Bell of AT&T Trademark Laboratories. -- Donn Seeley


devel / comp.lang.python / Re: divmod with negative Decimal values

SubjectAuthor
o Re: divmod with negative Decimal valuesThomas Passin

1
Re: divmod with negative Decimal values

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: divmod with negative Decimal values
Date: Tue, 22 Aug 2023 12:49:01 -0400
Lines: 35
Message-ID: <mailman.246.1692723353.23016.python-list@python.org>
References: <ef9bb1d6-8ee2-6d96-fc9b-20075536edb5@btinternet.com>
<54b65c84-8ced-4c29-d1e1-d19321886c8b@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de L895EAZB4OH8jseGWmbWygCx4RZI9ydyxzq8UnpSSOKw==
Cancel-Lock: sha1:ndFqYOmC0sUMCPmmFbm3ZzptOBk= sha256:q1PTm+wBKfPUIgWXWxtM50UukNhmLGej0vqcB6Ltpog=
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=pn9cV886;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'library.': 0.05; 'math':
0.05; 'expression': 0.09; 'float': 0.09; 'infinite': 0.09;
'import': 0.15; 'decimal': 0.16; 'float,': 0.16; 'integer': 0.16;
'intent': 0.16; 'precision)': 0.16; 'python\xe2\x80\x99s': 0.16;
'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'se,': 0.16; 'subject:values':
0.16; 'surprising': 0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr
:python-list': 0.20; 'returns': 0.22; 'cannot': 0.25; 'function':
0.27; 'example,': 0.28; 'header:User-Agent:1': 0.30; 'am,': 0.31;
'python-list': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32; "i'm": 0.33;
'same': 0.34; 'header:In-Reply-To:1': 0.34; "it's": 0.37; 'way':
0.38; 'here': 0.62; 'less': 0.65; 'generally': 0.67;
'header:Received:6': 0.67; 'received:64': 0.67; 'per': 0.68;
'exactly': 0.68; 'instead,': 0.70; 'practical': 0.84;
'represented': 0.84; 'rob': 0.84; 'rounds': 0.84; 'performs': 0.93
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1692722943; a=rsa-sha256;
cv=none;
b=Uidh9cWDQ5OwlIFX1bf1oWrHdDBq3D81eOKLIFNb+uoPw5uNl/JPEBkOWRqOrp5q6Knd/d
77hiCv9btzQTcPvcswd4kW8zGzjjldAxCNAWhX6NmXEq5biff+D2iUKjSY1LiB3VQL0E4U
lNVzJVnmuDwaQOdNwsikpZUQTJd1A8PXUKRqnmUTMuzR6MI8GpI70J9zzVU/dsCo4BF2nP
IBSkI8pG8zO39BLLctxRK6MwZAQzX3yejDFPQQz3R6Pqztzmr3UUpgdktMzFB4Zz0R9bzB
pEyMEQ7bqcCJDDG6OXcy0G5WCIg3AnBmQ8gVHV7mXEYHFQJfNwzJ8JXIZWYrDw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1692722943;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=chKDD+ugs9/Gw/8fxp35KoTy1LrATNDcB+wmjyfL2aI=;
b=Nq+KKK2ncICBMVMZhvn0dD+aoiHSdJXvDKoOWXyD2SWN8KHREP/p4KriBaANZj3E7/mVMv
pMHZgcIoHH+RDJt9aUzBPA5mWxpvL3nZxk6QnXYDxw5CqR7RjYxNPhU/YA6jHNnsBAHed8
FKgRSYA3LB5jSizgnDaxG1K4JGh5VFfPNFbWzV28T4akyCmh/0UlnqO+5NSVdXVDAgUaHP
ujnKUcWrODvysSjikVHvyQkiSc5MTL6zLhArJIwR53AHzevcM3J1VivvYFi/W5EJSLpkvE
pT2Vc4XepGzOYfweBPE4pJY3kPjuOvCIspLaLQt9TDv94EKDuhgedf60ozvEGQ==
ARC-Authentication-Results: i=1; rspamd-849d547c58-9gwpv;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Stupid-Print: 53b566c271fad3d1_1692722943553_845005854
X-MC-Loop-Signature: 1692722943553:3985197540
X-MC-Ingress-Time: 1692722943553
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1692722943;
bh=chKDD+ugs9/Gw/8fxp35KoTy1LrATNDcB+wmjyfL2aI=;
h=Date:From:Subject:To:Content-Type:Content-Transfer-Encoding;
b=pn9cV8866edPvq9tAGcHVPxAd/acHzOpBMl7nfN1gDX4OIBI1iL8JbL1IQvoF81jZ
/kIxJ/h5PkElwR4S4HK/UwSgwB42/qIJaGD+u64p1wXX6CUw871/GbNELTdTWN7xe9
6Jmoa6+yjAQIj6rEiyg38bUMgikWBW7gWjY/+TQypvVZtzwgojCzfJKreA3p4o9GQP
rQnv/HZoHJul2FUsZw0cC+w1bjr9TeFos4AFiKtVA+TETMT8gd5Nt1r/Ky/mGM8Gtf
DIIg4njxotbe2Nk4Gq9lX8d9Wxzvf7kNl8/zbfMYuZBNUOR9KTPsTZOoShLKHPSjEA
Lg30j4cDBuv6Q==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Content-Language: en-US
In-Reply-To: <ef9bb1d6-8ee2-6d96-fc9b-20075536edb5@btinternet.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: <54b65c84-8ced-4c29-d1e1-d19321886c8b@tompassin.net>
X-Mailman-Original-References: <ef9bb1d6-8ee2-6d96-fc9b-20075536edb5@btinternet.com>
 by: Thomas Passin - Tue, 22 Aug 2023 16:49 UTC

On 8/18/2023 5:14 AM, Rob Cliffe via Python-list wrote:
> divmod(Decimal("-1"), 60)

It's not divmod per se, but the modulus operation:

from decimal import Decimal
D1 = Decimal(-1)
D1 % 60 # Decimal(-1)

fmod() performs the same way:

from math import fmod
fmod(-1, 60) # -1.0

From the Python docs on math.fmod:

"math.fmod(x, y)
Return fmod(x, y), as defined by the platform C library. Note that the
Python expression x % y may not return the same result. The intent of
the C standard is that fmod(x, y) be exactly (mathematically; to
infinite precision) equal to x - n*y for some integer n such that the
result has the same sign as x and magnitude less than abs(y). Python’s x
% y returns a result with the sign of y instead, and may not be exactly
computable for float arguments. For example, fmod(-1e-100, 1e100) is
-1e-100, but the result of Python’s -1e-100 % 1e100 is 1e100-1e-100,
which cannot be represented exactly as a float, and rounds to the
surprising 1e100. For this reason, function fmod() is generally
preferred when working with floats, while Python’s x % y is preferred
when working with integers."

I'm not sure this is helpful in a practical way here ...

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor