[BUG] String>asNumber fails unless first char is legit digit
Tim Rowledge
tim at sumeru.stanford.edu
Wed Jun 26 23:19:57 UTC 2002
Try
'' asNumber
It correctly returns 0.
Now try
' ' asNumber
boom! Despite the comment in Integer class>readForom:base: claiming that
0 will be returned if no digit is found.
Likewise ' 3.1' fails.
I'd say that somewhere in the sequence of messages the debugger will
show you should be removing/skipping leading non-digits. It looks a
little extra complicated since I imagine leading non-digits in a radix'd
number would be improper (ie '16r 23' may well be improper, depending on
definitions I don't know the details of).
Lex, this method has your initials attached, so maybe you know the
gestalt of what is intended?
tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
A computer scientist is someone who fixes things that aren't broken.
More information about the Squeak-dev
mailing list
|