[Qt-interest] QString::toDouble with the string "Infinity"

Andre Haupt andre at bitwigglers.org
Thu Jun 25 08:43:16 CEST 2009


On Thu, Jun 25, 2009 at 01:12:57PM +0200, Rüdiger Meier wrote:
> Hi,
> 
> On Monday 22 June 2009, Julien Cugnière wrote:
> > It seems QString::toDouble knows how to convert a string such as
> > "inf", "-inf", or "nan" into the corresponding double representation.
> 
> I've got a similar question because I need to convert strings to double, 
> which were generated by Java's Double.toString, documented here:
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html#toString(double)
> 
> The Problem appears on the string "Infinity", which cannot be parsed by 
> QString::toDouble.
> 
> Is there any way to reproduce that java behavior exactly in Qt4/C++?
> Maybe QLocale::Javanese? ;)

Maybe
	s.replace(QString("Infinity"), QString("inf"));

or something like that?


regards,

Andre



More information about the Qt-interest-old mailing list