The maximum number of digits to expect input of.
The minimum amount of leading zeroes to include in the output, mirroring the format specifier "%0nd".
Integer to translate into string.
Output range sink.
Appender!(char[]) sink; int num = 12345; num.toAlphaInto(sink); assert(sink.data == "12345"); assert(sink.data == num.to!string);
import std.array : Appender; Appender!(char[]) sink; { enum num = 123_456; num.toAlphaInto(sink); assert((sink.data == "123456"), sink.data); sink.clear(); } { enum num = 0; num.toAlphaInto(sink); assert((sink.data == "0"), sink.data); sink.clear(); } { enum num = 999; num.toAlphaInto(sink); assert((sink.data == "999"), sink.data); sink.clear(); } { enum num = -987; num.toAlphaInto(sink); assert((sink.data == "-987"), sink.data); sink.clear(); } { enum num = 123; num.toAlphaInto!(12, 6)(sink); assert((sink.data == "000123"), sink.data); sink.clear(); } { enum num = -1; num.toAlphaInto!(3, 3)(sink); assert((sink.data == "-001"), sink.data); sink.clear(); } { enum num = -123_456_789_012_345L; num.toAlphaInto!15(sink); assert((sink.data == "-123456789012345"), sink.data); sink.clear(); } { enum num = long.min; num.toAlphaInto(sink); assert((sink.data == "-9223372036854775808"), sink.data); //sink.clear(); }
Translates an integer into an alphanumeric string. Assumes ASCII. Overload that takes an output range sink.