Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 26 |
Nodes: | 6 (1 / 5) |
Uptime: | 18:40:24 |
Calls: | 629 |
Files: | 1,186 |
D/L today: |
19 files (29,897K bytes) |
Messages: | 167,605 |
I could knock something up - all I need to do is total a ****** lot of
small numbers accurately, but the result is more than 64 bits.
Andy
I could knock something up - all I need to do is total a ****** lot of
small numbers accurately, but the result is more than 64 bits.
Andy
I could knock something up - all I need to do is total a ****** lot of
small numbers accurately, but the result is more than 64 bits.
Andy
I could knock something up - all I need to do is total a ****** lot
of small numbers accurately, but the result is more than 64 bits.
Andy
On Mon, 29 Sep 2025 21:08:09 +0100
Vir Campestris <vir.campestris@invalid.invalid> wrote:
I could knock something up - all I need to do is total a ****** lot
of small numbers accurately, but the result is more than 64 bits.
Andy
If you neeed just a little more than 64 bit then use 128-bit integers.
For decades gcc and clang feature a non-standard type __int128.
Or switch to better languge. Then you can use standard type
_BitInt(128). Or _BitInt(256). Or _BitInt(0x8000).
As a general rule, C is a decent improvement on its successor and that
is just one example.
_BitInt is likely coming to C++ too, though the details are not in
place yet. I'd guess any C and C++ compiler that supports _BitInt in
C23 will also accept it as a non-standard extension in C++.
I could knock something up - all I need to do is total a ****** lot
of small numbers accurately, but the result is more than 64 bits.
Andy
If you neeed just a little more than 64 bit then use 128-bit integers.I went away and thought about it. Then decided I'll never port this
For decades gcc and clang feature a non-standard type __int128.
On 30/09/2025 00:03, Michael S wrote:
On Mon, 29 Sep 2025 21:08:09 +0100
Vir Campestris <vir.campestris@invalid.invalid> wrote:
I could knock something up - all I need to do is total a ****** lot
of small numbers accurately, but the result is more than 64 bits.
Andy
If you neeed just a little more than 64 bit then use 128-bit integers.
For decades gcc and clang feature a non-standard type __int128.
Yes, that should be the easiest way - as long as the target has native 64-bit support.-a For 32-bit (or smaller) targets, gcc does not have __int128.
A simple "Int128" class with support for basic arithmetic should be
quick to write, however - especially if you don't need division.
Or switch to better languge. Then you can use standard type
_BitInt(128). Or _BitInt(256). Or _BitInt(0x8000).
As a general rule, C is a decent improvement on its successor and that
is just one example.
_BitInt is likely coming to C++ too, though the details are not in place yet.-a I'd guess any C and C++ compiler that supports _BitInt in C23 will also accept it as a non-standard extension in C++.
On 29/09/2025 23:03, Michael S wrote:Your post inspired me to do that myself (without having looked at the implementations for the standard integer types or thought about that at
If you neeed just a little more than 64 bit then use 128-bitI went away and thought about it. Then decided I'll never port this
integers. For decades gcc and clang feature a non-standard type
__int128.
code, so I used __int128. I then found that you can't write it out, so
I had to implement a string convert just to print the output!
Am Fri, 3 Oct 2025 17:05:38 +0100
schrieb Vir Campestris <vir.campestris@invalid.invalid>:
On 29/09/2025 23:03, Michael S wrote:
If you neeed just a little more than 64 bit then use 128-bitI went away and thought about it. Then decided I'll never port this
integers. For decades gcc and clang feature a non-standard type
__int128.
code, so I used __int128. I then found that you can't write it out, so
I had to implement a string convert just to print the output!
Your post inspired me to do that myself (without having looked at the implementations for the standard integer types or thought about that at
all ever before). This is what I came up with. It doesn't use
std::string to avoid overhead and respects the basefield and showbase manipulators (but only them). What do you think?
std::ostream& operator<<(std::ostream& out, signed __int128 k) {
if ((k<0) && (out.flags() & std::ios::dec)) {
out<<'-'; //output a minus sign
k*=-1; //change k to absolute value
On 10/6/2025 6:34 PM, Ralf Goertz wrote:Hm, maybe it should. But it doesn't:
Am Fri, 3 Oct 2025 17:05:38 +0100
schrieb Vir Campestris <vir.campestris@invalid.invalid>:
On 29/09/2025 23:03, Michael S wrote:
If you neeed just a little more than 64 bit then use 128-bitI went away and thought about it. Then decided I'll never port this
integers. For decades gcc and clang feature a non-standard type
__int128.
code, so I used __int128. I then found that you can't write it
out, so I had to implement a string convert just to print the
output!
Your post inspired me to do that myself (without having looked at
the implementations for the standard integer types or thought about
that at all ever before). This is what I came up with. It doesn't
use std::string to avoid overhead and respects the basefield and
showbase manipulators (but only them). What do you think?
std::ostream& operator<<(std::ostream& out, signed __int128 k) {
if ((k<0) && (out.flags() & std::ios::dec)) {
out<<'-'; //output a minus sign
k*=-1; //change k to absolute value
Wouldn't this fail with INT128_MIN? Just nit-picking!
On 9/29/2025 3:08 PM, Vir Campestris wrote:
I could knock something up - all I need to do is total a ****** lot of
small numbers accurately, but the result is more than 64 bits.
Andy
Its not too hard to do this using ASCII digits.
Then you have unlimited length.
Am 29.09.2025 um 22:40 schrieb olcott:
On 9/29/2025 3:08 PM, Vir Campestris wrote:
I could knock something up - all I need to do is total a ****** lot of
small numbers accurately, but the result is more than 64 bits.
Andy
Its not too hard to do this using ASCII digits.
Then you have unlimited length.
And how do you do the math with that ?
Bonita Montero <Bonita.Montero@gmail.com> writes:
Am 29.09.2025 um 22:40 schrieb olcott:
On 9/29/2025 3:08 PM, Vir Campestris wrote:
I could knock something up - all I need to do is total a ****** lot of >>>> small numbers accurately, but the result is more than 64 bits.
Andy
Its not too hard to do this using ASCII digits.
Then you have unlimited length.
And how do you do the math with that ?
mpz_init_set_str()
Am 07.10.2025 um 19:56 schrieb Scott Lurndal:
Bonita Montero <Bonita.Montero@gmail.com> writes:
Am 29.09.2025 um 22:40 schrieb olcott:
On 9/29/2025 3:08 PM, Vir Campestris wrote:
I could knock something up - all I need to do is total a ****** lot of >>>>> small numbers accurately, but the result is more than 64 bits.
Andy
Its not too hard to do this using ASCII digits.
Then you have unlimited length.
And how do you do the math with that ?
mpz_init_set_str()
The math isn't done with ASCII for that.