Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Things are not as simple as they seems at first. -- Edward Thorp


devel / comp.lang.python / CPython / Decimal and bit length of value.

SubjectAuthor
* CPython / Decimal and bit length of value.Nacnud Nac
`- Re: CPython / Decimal and bit length of value.jak

1
CPython / Decimal and bit length of value.

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: nacnud_uk27@yahoo.com (Nacnud Nac)
Newsgroups: comp.lang.python
Subject: CPython / Decimal and bit length of value.
Date: Fri, 3 Sep 2021 20:09:40 +0000 (UTC)
Lines: 13
Message-ID: <mailman.629.1630809184.4164.python-list@python.org>
References: <1771811707.3518631.1630699780851.ref@mail.yahoo.com>
<1771811707.3518631.1630699780851@mail.yahoo.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de jmCVBKeRG5ilzSY4JQrqKwlonC7espho7zVo7Zj/qJvA==
Return-Path: <nacnud_uk27@yahoo.com>
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=yahoo.com header.i=@yahoo.com header.b=GcFwkuen;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.122
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.76; '*S*': 0.00; 'bits': 0.16; 'decimal':
0.16; "it'd": 0.16; 'missing?': 0.16; 'received:77.238.177': 0.16;
'subject:CPython': 0.16; 'subject:bit': 0.16; 'subject:length':
0.16; 'to:addr:python-list': 0.23; 'seems': 0.26; 'function':
0.28; 'to:name:python-list@python.org': 0.28; 'there': 0.31;
"i'm": 0.32; 'structure': 0.32; 'subject: / ': 0.32; 'able': 0.36;
'way': 0.37; 'really': 0.37; 'something': 0.38; 'hi,': 0.39;
'sorry': 0.61; 'required': 0.66; 'received:77': 0.68; 'that,':
0.68; 'order': 0.68; 'obvious': 0.69; 'quick': 0.78; 'say,': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1630699783; bh=Ap8CU1nNRQWd5ZZLzCCFSlpVEwoJcOF+oocJpFozjUs=;
h=Date:From:To:Subject:References:From:Subject:Reply-To;
b=GcFwkuensAGSPINa6044RmExHoMJZWLAOMIrMJj3TNjBx+F5WaR5vXGq2xgwZu2uLZ1AirI2yKJVUYj3whROrK4eSOabmpUE29tfIy1I7s2Gp1OQoTDmIuLUf2hprsEFrP4vWSHZt8w5FrpFnkjpTq2U6gZdhzB6uRP1+iTWB5NB7PzIGSr7IAap7wJO98/SoZ0OEW4HtOOTma/yPvZaX6Nuo0CrlGzZeuZW6PDShc55yOuP+aDOYF4XZ3R6tfSppk+R/4RbzPe8hGCyF85EsE62hvKTMokhjZuYfnfjxSsYCoZl2ac+0lACvUhAzfohfSJj27Iv9MzZr/NF/v8Bbw==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1630699783; bh=pKYEyj2Ts1aYD8WQspDSsmOqtc9wXwEo5wkO8mir8dm=;
h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
b=rI6rBiaJ5RUnxJ3XEglWXT0l2DxxuOHZ1HIABvK6ozBbtZP3BxTqbOfY5uA6Mb0j5sHv1fVX/hw+epdgW1TlVVyTj9c2hzj7bAV80iueHZZVtvnfpVptrRpsRcaDpHRPSO0wurkyzDXRGn2csUwnr012DJvJxbbMJ8X1ZkUvRoSy9KG+e0GiizhN8O7NEKJtUsZMC5FIAnMp2IUnDDhpGSTrnttABLPZxdWsI26998wfIg3xfhTqWPH3PksWo8a/HCxPYnTJukU7ltT+XxCwq/OISgm/+piK4NpqEgdBZGvbwvi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c0tyeKWZSvY5ieQw8YmRZi2QGDsLBCsdOJJI8FerTuXxkAPx.whOw6vhA9
CrBOqvtEmmi4vTWX_jYcyWuZT7py1.V_qTulvE8ozuIiHE4hOkxU8ZlsFYCgA.MIwiiXEH27fyj7
nVZ_7ul_oRxR1MQf.MPYUUawukxQ3JTcok36fXaSqrfHaA071giAoG3zdbXdoWKtC.CKvBeDRq_o
9Q0JeFMBohf6Th7PrxuvSf_bySqzRNBKLy8GWadp9grE9z0m5Yf5bhQiHnZfHTcpe
X-Sonic-MF: <nacnud_uk27@yahoo.com>
X-Mailer: WebService/1.1.18924 YMailNorrin
X-Mailman-Approved-At: Sat, 04 Sep 2021 22:33:04 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.34
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <1771811707.3518631.1630699780851@mail.yahoo.com>
X-Mailman-Original-References: <1771811707.3518631.1630699780851.ref@mail.yahoo.com>
 by: Nacnud Nac - Fri, 3 Sep 2021 20:09 UTC

Hi,
Is there a quick way to get the number of bits required to store the value in a Decimal class? 
What obvious thing am I missing? I'm working with really large integers, say, in the order of 5_000_000 of ASCII base 10 digits. 
It seems the function mpd_sizeinbase would be a nice thing to be able to call.....
It'd be nice to just be able to tell the "size of data", or something like that, that was stored in the *data? I note there is len "field" in the structure mpd_t
Sorry for the dumb question....
Thanks,Duncan

Re: CPython / Decimal and bit length of value.

<sh2acd$11p5$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!U5gNWuGNbOBeY595qbMXuw.user.46.165.242.91.POSTED!not-for-mail
From: nospam@please.ty (jak)
Newsgroups: comp.lang.python
Subject: Re: CPython / Decimal and bit length of value.
Date: Sun, 5 Sep 2021 13:41:01 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sh2acd$11p5$1@gioia.aioe.org>
References: <1771811707.3518631.1630699780851.ref@mail.yahoo.com>
<1771811707.3518631.1630699780851@mail.yahoo.com>
<mailman.629.1630809184.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="34597"; posting-host="U5gNWuGNbOBeY595qbMXuw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: it
 by: jak - Sun, 5 Sep 2021 11:41 UTC

Il 03/09/2021 22:09, Nacnud Nac ha scritto:
> Hi,
> Is there a quick way to get the number of bits required to store the value in a Decimal class?
> What obvious thing am I missing? I'm working with really large integers, say, in the order of 5_000_000 of ASCII base 10 digits.
> It seems the function mpd_sizeinbase would be a nice thing to be able to call.....
> It'd be nice to just be able to tell the "size of data", or something like that, that was stored in the *data? I note there is len "field" in the structure mpd_t
> Sorry for the dumb question....
> Thanks,Duncan
>
to semplfy the example I'll use the value 1000000:

value="1000000"

exponent in base 10 is len(value) - 1 # (1 * 10^6)

now need change from base 10 to base 2: newexp = 6 / log(2) # 19 (more
or less)

you will need newexp + 1 bits to represent the number: 2^20 = 1.048.576

hope helps


devel / comp.lang.python / CPython / Decimal and bit length of value.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor