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[] == "12345"); assert(sink[] == num.to!string);
import std.array : Appender; Appender!(char[]) sink; { enum num = 123_456; num.toAlphaInto(sink); assert((sink[] == "123456"), sink[]); sink.clear(); } { enum num = 0; num.toAlphaInto(sink); assert((sink[] == "0"), sink[]); sink.clear(); } { enum num = 999; num.toAlphaInto(sink); assert((sink[] == "999"), sink[]); sink.clear(); } { enum num = -987; num.toAlphaInto(sink); assert((sink[] == "-987"), sink[]); sink.clear(); } { enum num = 123; num.toAlphaInto!(12, 6)(sink); assert((sink[] == "000123"), sink[]); sink.clear(); } { enum num = -1; num.toAlphaInto!(3, 3)(sink); assert((sink[] == "-001"), sink[]); sink.clear(); } { enum num = -123_456_789_012_345L; num.toAlphaInto!15(sink); assert((sink[] == "-123456789012345"), sink[]); sink.clear(); } { enum num = long.min; num.toAlphaInto(sink); assert((sink[] == "-9223372036854775808"), sink[]); //sink.clear(); }
Translates an integer into an alphanumeric string. Assumes ASCII. Overload that takes an output range sink.