--- a/SmallInteger.st Sun Jul 02 14:16:14 2017 +0200
+++ b/SmallInteger.st Sun Jul 02 14:16:49 2017 +0200
@@ -4157,7 +4157,7 @@
"Created: 1.3.1997 / 16:58:01 / cg"
!
-intlog10
+integerLog10
"return the truncation of log10 of the receiver.
The same as (self log:10) floor.
Stupid implementation, which is used to find out the number of digits needed
@@ -4166,45 +4166,67 @@
(i.e. without log)."
self > 0 ifTrue:[
- self < 10000 ifTrue:[
- self < 10 ifTrue:[^ 0].
- self < 100 ifTrue:[^ 1].
- self < 1000 ifTrue:[^ 2].
- ^ 3
- ].
- self < 100000000 ifTrue:[
- self < 100000 ifTrue:[^ 4].
- self < 1000000 ifTrue:[^ 5].
- self < 10000000 ifTrue:[^ 6].
- ^ 7
- ].
- self < 1000000000 ifTrue:[^ 8].
- SmallInteger maxBytes == 4 ifTrue:[
- "/ on a 32 bit machine, SmallInt cannot be larger
- ^ 9
- ].
-
- "/ 64 bit machine
- self < 100000000000000 ifTrue:[
- self < 10000000000 ifTrue:[^ 9].
- self < 100000000000 ifTrue:[^ 10].
- self < 1000000000000 ifTrue:[^ 11].
- self < 10000000000000 ifTrue:[^ 12].
- ^ 13
- ].
- self < 1000000000000000 ifTrue:[^ 14].
- self < 10000000000000000 ifTrue:[^ 15].
- self < 100000000000000000 ifTrue:[^ 16].
- self < 1000000000000000000 ifTrue:[^ 17].
- ^ 18.
+ self < 10000 ifTrue:[
+ self < 10 ifTrue:[^ 0].
+ self < 100 ifTrue:[^ 1].
+ self < 1000 ifTrue:[^ 2].
+ ^ 3
+ ].
+ self < 100000000 ifTrue:[
+ self < 100000 ifTrue:[^ 4].
+ self < 1000000 ifTrue:[^ 5].
+ self < 10000000 ifTrue:[^ 6].
+ ^ 7
+ ].
+ self < 1000000000 ifTrue:[^ 8].
+ SmallInteger maxBytes == 4 ifTrue:[
+ "/ on a 32 bit machine, SmallInt cannot be larger
+ ^ 9
+ ].
+
+ "/ 64 bit machine
+ self < 100000000000000 ifTrue:[
+ self < 10000000000 ifTrue:[^ 9].
+ self < 100000000000 ifTrue:[^ 10].
+ self < 1000000000000 ifTrue:[^ 11].
+ self < 10000000000000 ifTrue:[^ 12].
+ ^ 13
+ ].
+ self < 1000000000000000 ifTrue:[^ 14].
+ self < 10000000000000000 ifTrue:[^ 15].
+ self < 100000000000000000 ifTrue:[^ 16].
+ self < 1000000000000000000 ifTrue:[^ 17].
+ ^ 18.
].
^ self class
- raise:#domainErrorSignal
- receiver:self
- selector:#intlog10
- arguments:#()
- errorString:'logarithm of negative integer'
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#intlog10
+ arguments:#()
+ errorString:'logarithm of negative integer'
+
+ "
+ 99 integerLog10
+ 100 integerLog10
+ 101 integerLog10
+ (101 log:10) floor
+ 120 integerLog10
+ -1 integerLog10
+ "
+
+ "Created: / 02-07-2017 / 01:19:09 / cg"
+!
+
+intlog10
+ "return the truncation of log10 of the receiver.
+ The same as (self log:10) floor.
+ Stupid implementation, which is used to find out the number of digits needed
+ to print a number/and for conversion to a LargeInteger.
+ Implemented that way, to allow for tiny systems (PDAs) without a Float class
+ (i.e. without log)."
+
+ ^ self integerLog10
"
99 intlog10
@@ -4214,6 +4236,8 @@
120 intlog10
-1 intlog10
"
+
+ "Modified: / 02-07-2017 / 01:19:05 / cg"
! !
!SmallInteger methodsFor:'printing & storing'!