🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1175

Re: .5 against 0.5f

#1175
From: Chris M. Thomasson
Date: Fri, 30 Oct 2026 18:12
29 lines
2988 bytes
On 10/30/2026 3:06 AM, David Brown wrote:
> On 30/10/2026 10:39, chine.bleu wrote:
>> Janis Papanagnou wrote:
>>> Would there be a problem with fixed-point arithmetic (that internally
>>> uses a few more than just two decimals for rounding etc.) but that is
>>> using basically a fixed-point representation?
>> You could make a library for rational numbers (two integers) 
>> arithmetic where the denominator is a power of ten. If the CPU has 
>> decimal arithmetic, implement it in assembly.
>>
> 
> It does not make much sense to talk about a library for rational 
> numbers, then restrict it to denominators with powers of ten.  When you 
> need exactly reproducible decimals, one option is to use a fixed number 
> of places and then used scaled integers (a.k.a. fixed-point arithmetic) 
> - basically hold your values in "long long int" types with a constant 
> scale factor of 1'000'000, or similar.
> 
> If you want to be able to handle different scale factors easily, then 
> decimal floating point formats are appropriate.  These are standardised 
> in ISO/IEC 60559, and supported in C as _Decimal32, _Decimal64 and 
> _Decimal128.  The types are optional in C, but supported at least by gcc 
> on "big" target systems.  If the target hardware has appropriate 
> instructions for them, the compiler should use that - that is vastly 
> better than using assembly.
> 

Try to gain a rational that fits for a given precision for a target 
real? Convergents of continued fractions?
Technical Details
Message-ID: <11c2mmu$fu1j$1@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> <11c0plh$3s02c$1@dont-email.me> <11c14qg$2t866$7@dont-email.me> <11c1ok8$469v$1@dont-email.me> <11c1q7s$4tso$1@dont-email.me>

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: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Fri, 30 Oct 2026 11:12:45 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <11c2mmu$fu1j$1@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>
 <11c0plh$3s02c$1@dont-email.me> <11c14qg$2t866$7@dont-email.me>
 <11c1ok8$469v$1@dont-email.me> <11c1q7s$4tso$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 30 Oct 2026 18:12:47 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="522291"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+HsE8EaWnfzbkHAZik6l+BZVbaDU5aq6M="; posting-host="7a8a6c91a5763134c8ce1b9ee3cf1688"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Rg3LJPhz9G7fK15pAYdnWKvGmC8= sha256:aqoHhg5Bx+le4eyoXYuBcZ1Oxs3Z7wlNBCeBPs9Mn7I=
	sha1:6bMOf6eSv3sKz7KAtd2QJ2OfZ1Y= sha256:3kb1kuHsi6sEAq0MpQy4nEaRTVysO+AsIf/w2+Lh46A=
In-Reply-To: <11c1q7s$4tso$1@dont-email.me>
Content-Language: en-US