🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1161

Re: .5 against 0.5f

#1161
From: David Brown
Date: Fri, 30 Oct 2026 10:06
25 lines
2747 bytes
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.
Technical Details
Message-ID: <11c1q7s$4tso$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>

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: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Fri, 30 Oct 2026 11:06:51 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <11c1q7s$4tso$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 30 Oct 2026 10:06:52 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="161688"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/xstkV2pAsLr6rXUmG0bOgRwG6nia5Fdw="; posting-host="005feb7eca873ed1ea966324157898e1"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cdzhUzoRYaB9ASKh/y8cTfOYtyo= sha256:G7lz8300GvxXMVmgrgPJL4bFqIG+kQsOyKDfvOGCjHc=
	sha1:H8dZw7PlmyNQWxUsaA5mRH2kDUo= sha256:DMy+ypQfa8Nz7AstLhzdg/8xsglhUasPQzItb3Lx2ak=
Content-Language: en-GB, nb-NO
In-Reply-To: <11c1ok8$469v$1@dont-email.me>