Sujet : Re: "A diagram of C23 basic types"
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.cDate : 26. Jun 2025, 14:57:04
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103jjjh$3g1ce$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 26/06/2025 11:01, Lawrence D'Oliveiro wrote:
On Mon, 28 Apr 2025 16:27:38 +0300, Michael S wrote:
IMHO, a need for a common name for IEEE binary128 exists for quite some
time. For IEEE binary256 the real need didn't emerge yet. But it will
emerge in the hopefully near future.
A thought: the main advantage of binary types over decimal is supposed to
be speed. Once you get up to larger precisions like that, the speed
advantage becomes less clear, particularly since hardware support doesn’t
seem forthcoming any time soon. There are already variable-precision
decimal floating-point libraries available. And with such calculations, C
no longer offers a great performance advantage over a higher-level
language, so you might as well use the higher-level language.
<https://docs.python.org/3/library/decimal.html>
That is certainly a valid viewpoint. Much of this depends on what you are doing, how big the types are, what you are doing with them, how much of your code is calculations, and what other things you are doing.
If you are doing lots of calculations with big numbers of various sizes, then Python code using numpy will often be faster than writing C code directly - you can concentrate on writing better algorithms instead of all the low-level memory management and bureaucracy you have in a lower level language. (Of course the hard work in libraries like numpy is done in code written in C, Fortran, C++, or other low-level languages.)
But if you are using a type that is small enough to fit sensibly on the stack, and to have a fixed size (rather than arbitrary sized number types), then it is likely to be more efficient to define them as structs in C and use them directly. Depending on what you are doing with them, you might be better off using decimal-based types rather than binary-based types. (And at the risk of incurring Richard's wrath, I would suggest C++ is an even better language choice in such cases.)