Float parsing from string with radix?

David T. Lewis lewis at mail.msen.com
Wed Nov 24 17:09:46 UTC 2004


Integers can be represented with strings in a radix notation, and can be
printed with a radix notation.

	'8r107' asNumber => 71
	'2r1000111' asNumber => 71

	71 printStringRadix: 8 => '107'
	71 printStringRadix: 2 => '1000111'

Floats cannot be printed with radix notation, but Squeak permits them to
be represented with strings.

	'2r1.0101e9' asNumber => 672.0
	672.0 printStringRadix: 2 => message not understood

But this seems wrong to me. I would have expected the radix prefix to
have applied to both the base and the exponent, such that one would write
'2r1.0101e1001' rather than '2r1.0101e9'.

Or perhaps Float is not supposed to be represented this way at all,
in which case '2r1.0101e9' asNumber should evaluate as 1.3125 (ignoring
the trailing 'e9' in the string), and the current implementation (feature?)
in Squeak is a bug.

What is the preferred interpretation? 
  A) Leave it alone, it's a feature (but should be documented)
  B) Change it to interpret exponent with same radix as base
  C) Get rid of it, it's a bug


-Dave




More information about the Squeak-dev mailing list