🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1132

Re: .5 against 0.5f

#1132
From: Janis Papanagnou
Date: Thu, 29 Oct 2026 22:19
27 lines
2427 bytes
On 2026-10-29 13:01, Keith Thompson wrote:
> makendo <makendo@makendo.invalid> writes:
>>> I ordered a couple of blu-rays from amazon last week, and the
>>> confirmation email had the following for the total price:
>>>      Total
>>>      75.71000000000001 USD
>>> Appears they may be using FP instead of integer fixed point
>>> arithmetic
>>> for pricing.
>>
>> And this is why you should use the lowest value denominator when
>> storing monetary values -- store USD values in cents, CNY values
>> in fen, EUR values in cents, etc...
> [...]
> 
> That's not good enough.  Discounts, sales taxes, and compound
> interest can easily result in amounts that are not multiples of
> one cent, which must then be rounded or truncated to the nearest
> cent following whatever financial rules are in effect.

We also have to consider conversions of currencies between states
in international trade, or, at times, switch of a currency unit;
e.g. 1 Euro = 1,95583 DEM (note the officially defined number of
decimals).

Janis
Technical Details
Message-ID: <11c0gq4$2t865$3@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <Ue6ES.2265$y_V1.1859@fx12.iad> <11bv5o7$37qph$1@dont-email.me> <11bvcii$3a06t$3@kst.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Thu, 29 Oct 2026 23:19:48 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <11c0gq4$2t865$3@dont-email.me>
References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me>
 <Ue6ES.2265$y_V1.1859@fx12.iad> <11bv5o7$37qph$1@dont-email.me>
 <11bvcii$3a06t$3@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Oct 2026 22:19:49 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3055813"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/W8+FgoeRd/DdQ5JcqQQm+"; posting-host="5e472b3107e6c2ac767abee4ba3b623e"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:/58C905A6dqUvpbhYoJ/ikDu+LU= sha256:jAxsfsOy7BSr/niq24zFwGVEYbX0tzqgN5JdYGaKMcI=
	sha1:/qX7V8+Xt0T2yhTbrUBteUFpRiE= sha256:W1i+a5qwRcZoJoXYg3cKZ6bAAgbUx6s0/RZHPgJdulI=
Content-Language: en-US
In-Reply-To: <11bvcii$3a06t$3@kst.eternal-september.org>