[Qt-interest] Inconsistent toInt

Malyushytsky, Alex alex at wai.com
Mon Jan 11 17:51:19 CET 2010


I would not document all the details of implementation.
The string you are talking about is not a number. 
It requires conversion to be present as one.

Normally in such cases you deal with "undefined behavior".
This may be reported as a bug, cause consistency is great even in questionable cases.
Eventually it might be even fixed, but I argue that there is a reason to document such behavior.

Regards,
        Alex


-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Nikolay Moskvichev
Sent: Monday, January 11, 2010 5:00 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Inconsistent toInt

Hello, Malyushytsky, Alex
05.01.2010 3:17 you wrote:
> Instead of relying on questionable non-documented features,
> it seems reasonable to provide all mentioned functions string without leading and tailing spaces,
> isn't it?
> 

it seems reasonable to provide some notes in the documentation if two
methods with same functionality behaves differently, isn't it?


> Regards,
>    Alex
> 
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Nikolay Moskvichev
> Sent: Wednesday, December 30, 2009 9:18 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Inconsistent toInt
> 
> Hello, Constantin Makshin
> 30.12.2009 19:18 you wrote:
>> It's the intended behavior — QByteArray::toInt() fails if "stopped at a
>> non-digit character after converting some digits" (a quote from a comment
>> in QLocalePrivate::bytearrayToLongLong() function that's used by
>> QByteArray::toInt()).
>>
> 
> Then this should be described in the documentation IMO, and strange
> thing for me here is that QByteArray::toInt() successfully skip leading
> space
> 
>> On Tue, 29 Dec 2009 07:34:51 +0300, Nikolay Moskvichev
>> <nikolay.moskvichev at gmail.com> wrote:
>>> Hello, i currently use Qt 4.6 and looks like there is inconsistent
>>> behaviour in toInt methods of QByteArray and QString.
>>>
>>> bool siccess;
>>> int res = QByteArray( "0001 " ).toInt(&siccess);
>>>
>>> Now res == 0, siccess == false.
>>>
>>> Next turn:
>>>
>>> int res = QString( "0001 " ).toInt(&siccess);
>>>
>>> Now res == 1, siccess == true.
>>>
>>> More ower:
>>>
>>> int res = QByteArray( " 0001" ).toInt(&siccess);
>>>
>>> Now res == 1, siccess == true.
>>>
>>> For me it looks like bug in QByteArray.toInt
>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> 
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
> 
> “This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
> 
> “Please consider our environment before printing this email.”
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list