"Change Set: abstractStringAsUnsignedInteger-brp Date: 4 October 2004 Author: Brent Pinkney
Refactor AbstractString>>#asUnsignedInteger.
Update 6286 AbstractStringAsIntegerTweak-laza fixes String>>#asInteger. The implementation can be improved.
The logic in AbstractString>>#asUnsignedInteger is essentially duplicated in as#Integer.
An unsigned integer is merely the absolute value of a signed integer.
Passes all tests in MultiStringTest
Hence:
asUnsignedInteger ^ self asSignedInteger ifNotNilDo: [:i | i abs]
"
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I made the second version of that fix in a hurry and just noticed that after I submitted the code. I hesitated to send a changed fix right away, because I had doubts that this is really the best solution. Now I think we better should make asInteger be equivalent to asNumber
asInteger ~ ^Integer readFromString: self
and have a new method firstInteger (or extractFirstInteger) that does the job of former asInteger, but to return 0 instead of nil in case there are no digits in the string. This would be the changes for the senders
asInteger firstInteger asSignedInteger firstInteger asUnsignedInteger firstInteger abs
Alex
Hi guys
can one of you summarise the situation: we are unstable so we can remove changes in no time?
Stef
On 5 oct. 04, at 00:22, Alexander Lazarević wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I made the second version of that fix in a hurry and just noticed that after I submitted the code. I hesitated to send a changed fix right away, because I had doubts that this is really the best solution. Now I think we better should make asInteger be equivalent to asNumber
asInteger ~ ^Integer readFromString: self
and have a new method firstInteger (or extractFirstInteger) that does the job of former asInteger, but to return 0 instead of nil in case there are no digits in the string. This would be the changes for the senders
asInteger firstInteger asSignedInteger firstInteger asUnsignedInteger firstInteger abs
Alex -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBYc0yYiF2wSTEZ9gRAuEaAKDkfsE81Z0N4z2nCXgKGr56cvnDEgCgzgWd 6r+5B0eLePZj4k7/b11hEwg= =yQm+ -----END PGP SIGNATURE-----
squeak-dev@lists.squeakfoundation.org