On 12/23/2015 02:29 PM, Andrew Chapman wrote: > string v = toChars!(16,char,LetterCase.lower)(i); > > to convert an integer to Hex for example, but the compiler wasn't happy > with it. How would I convert an int to a string using this?
I had to squint at the error message to understand that the 16 specialization for radix requires that the value is unsigned. The following works:
import std.conv; import std.algorithm; void main() { assert(1234u // <-- unsigned .toChars!(16, char, LetterCase.lower) .equal("4d2")); } Ali