Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Can this program be improved? Date: Tue, 04 Jan 2022 15:47:39 -0800 Organization: None to speak of Lines: 35 Message-ID: <87lezvysf8.fsf@nosuchdomain.example.com> References: <87v8z41efe.fsf@nosuchdomain.example.com> <87r19s13w2.fsf@nosuchdomain.example.com> <9cca58b2-8310-45bb-98ac-4b71dc267a90n@googlegroups.com> <87k0fj12r3.fsf@nosuchdomain.example.com> <0858a55c-fdd7-4aa8-9c56-0ec3b04840f4n@googlegroups.com> <87bl0t1l05.fsf@nosuchdomain.example.com> <8735m41lwy.fsf@nosuchdomain.example.com> <87y23wz9l9.fsf@nosuchdomain.example.com> <5700fe69-acd6-4700-8b40-e48ad349fe33n@googlegroups.com> <87tuejyx2z.fsf@nosuchdomain.example.com> <1393d15f-e5ba-4ff2-977c-0618f457e0ebn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="0901cb002f24d9c5d5c18296a5778f80"; logging-data="10164"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1X5V8yFvsL1L0zk0xs/ev" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:5L2V5VDyTJInXYyG3B0L97DQzSc= sha1:wetuW81kPSaJgW0K3VNF27iseKw= Xref: csiph.com comp.lang.c:164294 Malcolm McLean writes: > On Tuesday, 4 January 2022 at 22:07:12 UTC, Keith Thompson wrote: >> Malcolm McLean writes: >> [...] >> > The central difficulty is that people have no problem with the idea >> > that an integer type should hold an amount in cents. But for some reason >> > they think that a floating point type must hold an amount in dollars. >> > Probably because an amount of 110 cents is always written as 1.10 >> > dollars for the end-user. >> > >> > Once you make that leap, you'll see that you can use floating point types to >> > represent integers. >> >> Or -- now hear me out -- you can use integers to represent integers. >> > Yes, but a floating point type degrades gracefully as values get very large. You're assuming that degradation is acceptable if it's "graceful". If you know something about the actual regulations that implies that, by all means share it. My speculation is that regulations require specific results to be accurate to the cent regardless of the magnitude of the quantities being used, and that hyperinflation would not be accepted as an excuse for off-by-one errors. If for whatever reason we started having to deal with quantities that don't fit in 64 bits, for example, perhaps some software would have to be updated -- or perhaps it can already handle such cases. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */