[BUG][FIX]numbers in scientific notation with capital E are nothandled correctly (not good)

Baveco, Hans Hans.Baveco at wur.nl
Wed Dec 1 21:30:37 UTC 2004


OK, that's clear. It felt already too goo to be true... (I never think hexadecimal). Funny how much knowledge and experience there is behind many methods in basic squeak/smalltalk. A pity though that so little is documented in/near the source :-(.
Wrt my problem of reading the uppercase exponent: the method Number>>readRemainderOf:from:base:withSign:
is executed after having read the 'front' part of the number. Do we not know already whether the number is a decimal number or not? In other words, would it be possible to limit this check (peekChar = $E) to decimal numbers only?
I might overlook complications again, though.. but it is just not an attractive option, having to scan every possible input file for occurrences of $E.
 
Thanks a lot for your informative reply,
 
Hans

	-----Original Message----- 
	From: Bert Freudenberg [mailto:bert at impara.de] 
	Sent: Wed 12/1/2004 7:33 PM 
	To: The general-purpose Squeak developers list 
	Cc: 
	Subject: [BUG][FIX]numbers in scientific notation with capital E are nothandled correctly (not good)
	
	


	Am 01.12.2004 um 10:15 schrieb Baveco, Hans:
	
	> I have often been bit by this feature of squeak. '1234.123E-5'
	> asNumber produces 1234.123 because the exponent part is ignored. Some
	> numeric software produces output in this format, and reading datafiles
	> from such programs may lead to very hard to trace anomalies
	> (especially when scientific notation is only used for some of the
	> numbers). A simple one-liner change in
	> Number>>readRemainderOf:from:base:withSign: seems sufficient to handle
	> capital E, see attached fileout.
	>
	> I changed "peekChar = $e | (peekChar = $d) | (peekChar = $q)"
	>
	> to "((((peekChar == $e) or: [peekChar == $E]) or: [peekChar == $d])
	> or: [peekChar == $q])"
	>
	> (I compensated for the extra check by replacing the bars by blocks).
	>
	> I can't imagine there are any unwelcome side-effects associated with
	> this change?
	
	It changes the language, as this method is also used for reading
	literal numbers. I've been down that road before and was educated by
	Dan Ingalls that things are as they are for a reason.
	
	The reason in this case is that uppercase letters are reserved for
	digits (think hexadecimal). You can enter literal floats up to base 36
	in Smalltalk: 16rABC.DEF
	
	So, just convert your numbers to lowercase before reading them in.
	
	- Bert -
	
	
	

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 6262 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041201/61c5be14/attachment.bin


More information about the Squeak-dev mailing list