Sujet : Re: Suggested method for returning a string from a C program?
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.cDate : 22. Mar 2025, 15:07:43
Autres entêtes
Organisation : To protect and to server
Message-ID : <vrmg7d$2nif7$2@paganini.bofh.team>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
Kaz Kylheku <
643-408-1753@kylheku.com> wrote:
On 2025-03-22, bart <bc@freeuk.com> wrote:
The point is that there was usually a size exactly double the width of
'int', but it become less necessary when 'int' reached 64 bits.
Yes, because other than for masks of 128 bits, there isn't a whole
lot of stuff you can *count* for which you need such large integers.
Money?
In an accounting system, if you use signed 64 bits for pennies, you can
go to 9.2 x 10^16 dollars.
Actually, to do fast division of N-bit number by fixed N-bit number
one need 2N-bit multiplication. Such divisions appear in base
convertions (to decimal) and when doing "decimal" rounding.
Also, converting between currencies needs extra accuracy. So
_fast_ financial arithmetic may need rather large number of digits,
current tendecy is to allow up to 37 digits in intermediate quantities.
Note that 64-bit _result_ type means that 32-bit integers are
largest that can be multiplied exactly, that is very limiting.
Large integers are needed for crypto and such, but then 128 isn't enough
anyway.
Double word arthmetic is crucial if you want efficient high-level
implementation of multiple precision arithmetic. So, 64-bit is
enough on 32-bit machines, 128-bit is needed on 64-bit machines
and hypotetical 128-bit machines would need 256-bit integer
type as a building block for efficient multiple precision
arithmetic.
-- Waldek Hebisch