www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.string.toString() with radix function

reply Phoenix <phoenix flareware.cz> writes:
socket.d(111): function std.string.toString called with argument types:
         (ulong,int)
matches both:
         std.string.toString(long,uint)
and:
         std.string.toString(ulong,uint)


code:

int i = 15;
char [] ui;
ui = std.string.toString(cast(ulong)i,16);

what`s up with it?
Jun 02 2005
parent reply "Uwe Salomon" <post uwesalomon.de> writes:
 socket.d(111): function std.string.toString called with argument types:
          (ulong,int)
 matches both:
          std.string.toString(long,uint)
 and:
          std.string.toString(ulong,uint)


 code:

 int i = 15;
 char [] ui;
 ui = std.string.toString(cast(ulong)i,16);

 what`s up with it?
The parameter 16 is signed int by default. D has far simpler overloading rules than C++, and these produce the collision here. Use that instead: ui = std.string.toString(cast(ulong)i, 16u); Ciao uwe
Jun 02 2005
parent Phoenix <phoenix flareware.cz> writes:
Uwe Salomon napsal(a):
 socket.d(111): function std.string.toString called with argument types:
          (ulong,int)
 matches both:
          std.string.toString(long,uint)
 and:
          std.string.toString(ulong,uint)


 code:

 int i = 15;
 char [] ui;
 ui = std.string.toString(cast(ulong)i,16);

 what`s up with it?
The parameter 16 is signed int by default. D has far simpler overloading rules than C++, and these produce the collision here. Use that instead: ui = std.string.toString(cast(ulong)i, 16u); Ciao uwe
thanks, it works fine.
Jun 02 2005