News for hackers. Stuff that matters.
Re:C23 is finished: Here is what is on the menu by orlp on Friday August 05, 2022 @05:50AM (#32353818)
To the first problem you can use a classic mod 10 divide by 10 loop to convert into a string digit by digit.

Similarly for the second problem you can read digit by digit in reverse order and create the number using x = 10x + d while detecting overflow.

I'm not saying that this is a great thing to need to do, but the mentioned problems aren't particularly fundamental and the solutions are CS101 stuff.

Re:C23 is finished: Here is what is on the menu by teddyh on Friday August 05, 2022 @06:07AM (#32353963)
You may be right that it’s the best solution. It’s horrible to contemplate, but it might be so.
Re:C23 is finished: Here is what is on the menu by jcranmer on Friday August 05, 2022 @09:57AM (#32356172)
The best solution is to say that uid_t et al are probably no larger than uint64_t, and introducing a static_assert that makes sure that the compiler will fail if it's not.

Sure, someone might come up with an architecture where that's not true. But even in an intmax_t-is-really-the-largest-integer-type world [which hasn't been true for the major C compilers for the past decade or so!], I can almost assuredly come up with some compilation modes that still conform with whichever C version you use that still causes your code to fail horribly. I don't think there's any architecture where uid_t et al would exceed uint64_t, and until such an architecture comes to exist, it's quite frankly not worth caring about.

Re:C23 is finished: Here is what is on the menu by orlp on Friday August 05, 2022 @06:18AM (#32354046)
Oh I agree, it's bad.
Re:C23 is finished: Here is what is on the menu by csmpltn on Friday August 05, 2022 @08:48AM (#32355324)
> "To the first problem you can use a classic mod 10 divide by 10 loop to convert into a string digit by digit."

But the "physical" size of the number as represented in memory can change across platforms, no?