Stephan Bergmann wrote:
<http://www.openoffice.org/issues/show_bug.cgi?id=74781> claims that erroneously

  rtl::OUString::createFromAscii("0xFF11FF11").toInt32 == 0x0FF11FF1

Just for the records, we are talking about
rtl::OUString::createFromAscii("0xFF11FF11").toInt32( 16 ) == 0x0FF11FF1
                                                    ^^^^^^

Looking at the code (sal/rtl/source/strtmpl.c:1.22 l. 858 ff), this seems to be by desing: only use in the toInt32 conversion the longest prefix of the string that does not lead to numeric overflow. This is not specified in the documentation of rtl::OUString::toInt32 or rtl_ustr_toInt32, however.

Any objections against changing this behavior, so that toInt32 consumes all the string's digits and silently wraps on overflow (just as all the C/C++ operators do for signed integral types, at least on all today's hardware)? And similarly for toInt64 and rtl::OString, and the corresponding C functions rtl_ustr_toInt32 etc.

I agree with you to change the bahaviour, I think most users expect to see the least significant digits in the converted value, and you can argue that "FFFFFFFF" is a commonly used hexadecimal representation of the signed integer -1.

Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to