D: Convert/parse uint integer to string. (@nogc)

kdevel kdevel at vogtner.de
Thu Nov 30 22:47:40 UTC 2023


On Tuesday, 28 November 2023 at 09:43:47 UTC, Dom DiSc wrote:
> On Tuesday, 28 November 2023 at 08:51:21 UTC, Mark Davies wrote:
>> On Friday, 24 November 2023 at 09:35:00 UTC, BoQsc wrote:
>> ```
>> import std.stdio;
>>
>> char[10] longToString(long n) @nogc
>> ```
>
> For a 'long' 10 characters is likely to be not enough (long max 
> is 9223372036854775808 [...]

`long.max` is 9223372036854775807, `long.min` is 
-9223372036854775808. Besides from the too short buffer the 
`longToString` function neither converts 0 (zero) nor `long.min` 
correctly.




More information about the Digitalmars-d-learn mailing list