Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Issues with tango.util.Convert

Moderators: kris

Posted: 02/02/09 16:12:51 Modified: 02/18/09 10:24:36

Hi, with the latest SVN version, I get the following errors in tango.util.Convert:

to!(float)("Foo") returns 0 (should throw ConversionException?).

to!(float)("") throws an AV in the runtime:

Error: Access Violation (object.Exception)
backtrace:
 004042d1 tango.text.convert.Float.parse!(char) (+49) import\tango\text\convert\Float.d:308
 0040479b tango.util.Convert.toReal!(float, char[0]) (+13) import\tango\util\Convert.d:837
 00404786 tango.util.Convert.toImpl!(float, char[0]) (+e) import\tango\util\Convert.d:1047
 00404772 tango.util.Convert.to!(float).to!(char[0], tango.util.Convert.Missing) (+e) import\tango\util\Convert.d:148

It seems, tango.util.Convert.toReal is missing some error checking (like toIntegerFromString).

EDIT: another one: to!(float)("0x1.2cp+9") returns -nan (wtf?), whereas toFloat("0x1.2cp+9") throws ConversionException? (not nice, but better). Is there no support for hexadecimal exponential notation of floats in tango?

Third (I'm not sure if this is intended behavior),
to!(int)("") returns 0.

Sorry if this has already been reported, but I couldn't find a ticket for this problem. Thanks for looking into this.

EDIT2: Creating a ticket, since nobody seems to care.

Author Message

Posted: 02/18/09 11:45:18

Thanks for the report, if it looks like an error that is normally the correct approach in any case. Also, with a ticket there is a better guarantee that you'll get a reply :)