[ENH] IntegerPrintOnPadding

Alexander at Lazarevic.de Alexander at Lazarevic.de
Tue Mar 30 12:50:18 UTC 2004


Added a few tests and fixed two bugs. The previous version of
Integer>>printStringBase:
decreased performance up to a factor of 2. Now it runs in about the same
time as the
original equivalent.

from preamble:

"Change Set:		IntegerPrintOnPadding
Date:			29 March 2004
Author:			Alexander Lazarevic

This changeset improves and changes (a little) the way integers can be
printend in different numeratives.

* The meaning of printStringBase has changed. printStringBase: will just
print
a number in any base and the (new) storeStringBase: will print the
number with a leading base.

Examples:

3994 printStringBase: 16	-->	'F9A'
3994 storeStringBase: 16	-->	'16rF9A'

* The new method printOn:base:length:padded: (et al) helps formatting
output a little.

Examples:

3735928559 printStringBase: 16 length: 20 padded: false	-->	'           
DEADBEEF'
3735928559 printStringBase: 16 length: 20 padded: true	-->
'000000000000DEADBEEF'
3735928559 storeStringBase: 16 length: 20 padded: true	-->
'16r000000000DEADBEEF'
-3735928559 storeStringBase: 16 length: 20 padded: false	-->	'       
-16rDEADBEEF'

* Some redundant code got removed, some methods got deprecated and some
moved.As one
result Fractions now can also respond to printOn:base: like Integers and
Floats (just to be consistent).

Examples:
(15/11) printStringBase: 16	-->	'(F/B)'
(15/11) storeStringBase: 16	-->	'(16rF/16rB)'
		
The following worked before:
(16rF/16rB) printString	-->	'(15/11)'

* For more examples see the IntegerPrintOnPaddingTests changeset and the
classes IntegerTests and
FrationTests
"!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IntegerPrintOnPadding.cs.gz
Type: application/octet-stream
Size: 2037 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040330/49838c35/IntegerPrintOnPadding.cs.obj


More information about the Squeak-dev mailing list