--- a/Number.st Wed Oct 28 09:09:42 2015 +0100
+++ b/Number.st Wed Oct 28 09:12:33 2015 +0100
@@ -17,7 +17,8 @@
ArithmeticValue subclass:#Number
instanceVariableNames:''
- classVariableNames:'DecimalPointCharacterForPrinting DecimalPointCharactersForReading'
+ classVariableNames:'DecimalPointCharacterForPrinting DecimalPointCharactersForReading
+ DefaultDisplayRadix'
poolDictionaries:''
category:'Magnitude-Numbers'
!
@@ -1319,7 +1320,8 @@
!
ln
- "compute ln of the receiver"
+ "return the natural logarithm of myself.
+ Raises an exception, if the receiver is less or equal to zero."
(self isLimitedPrecisionReal not
or:[self generality < 1.0 generality]) ifTrue:[
@@ -1446,6 +1448,39 @@
!Number methodsFor:'printing & storing'!
+printOn:aStream
+ "append a printed description of the receiver to aStream"
+
+ self printOn:aStream base:10
+
+ "Modified: / 20.1.1998 / 14:10:45 / stefan"
+!
+
+printOn:aStream base:b
+ "return a string representation of the receiver in the specified
+ radix (without the initial XXr)"
+
+ ^ self printOn:aStream base:b showRadix:false
+
+ "
+ 10 printOn:Transcript base:3
+ 31 printOn:Transcript base:3
+ -20 printOn:Transcript base:16
+ -20 printOn:Transcript base:10
+ 3000 factorial printOn:Transcript base:10
+ "
+
+ "Modified: / 20.1.1998 / 18:05:02 / stefan"
+ "Modified: / 7.9.2001 / 13:52:17 / cg"
+!
+
+printOn:aStream base:b showRadix:showRadix
+ "the central print method for integer.
+ Must be defined in concrete classes"
+
+ self subclassResponsibility
+!
+
printOn:aStream paddedWith:padCharacter to:size base:radix
|s|
@@ -1540,6 +1575,21 @@
"
!
+printStringRadix:base showRadix:showRadixBoolean
+ "return a string representation of the receiver in the specified
+ base; does NOT prepend XXr to the string.
+ See also: radixPrintStringRadix:
+ printOn:base:showRadix:"
+
+ |s|
+
+ s := WriteStream on:(String basicNew:20).
+ self printOn:s base:base showRadix:showRadixBoolean.
+ ^ s contents
+
+ "Created: / 23-09-2011 / 13:59:19 / cg"
+!
+
printStringWithThousandsSeparator
"print the receiver as swiss business number with thousands separator to aStream.
Caveat: Should use the separator from the locale here"
@@ -1604,6 +1654,25 @@
"
!
+radixPrintStringRadix:radix
+ "return a string representation of the receiver in the specified
+ base; prepend XXr to the string"
+
+ ^ self printStringRadix:radix showRadix:true
+
+ "
+ 31 radixPrintStringRadix:2
+ 31 radixPrintStringRadix:3
+ 31 radixPrintStringRadix:10
+ 31 radixPrintStringRadix:16
+ 31 radixPrintStringRadix:36
+ "
+
+ "Created: / 19-01-1998 / 17:38:00 / stefan"
+ "Modified: / 20-01-1998 / 14:11:03 / stefan"
+ "Modified: / 23-09-2011 / 14:00:02 / cg"
+!
+
storeOn:aStream
"append a string for storing the receiver onto the argument, aStream
- since numbers are literals,they store as they print."