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!
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:
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.
Sysop: | Tetrazocine |
---|---|
Location: | Melbourne, VIC, Australia |
Users: | 14 |
Nodes: | 8 (0 / 8) |
Uptime: | 189:37:03 |
Calls: | 178 |
Files: | 21,502 |
Messages: | 79,909 |