diff -r 2cea97649a40 -r 95ff2af6355f Integer.st --- a/Integer.st Sun Jul 02 01:10:17 2017 +0200 +++ b/Integer.st Sun Jul 02 14:16:14 2017 +0200 @@ -3567,6 +3567,41 @@ "Modified: / 25.10.1997 / 16:08:45 / cg" ! +integerLog10 + "return the floor of log10 of the receiver. + This is the same as (self log:10) floor. + Used to find out the number of digits needed + to print a number/and for conversion to a LargeInteger." + + ^ self asFloat log10 floor + + " + 10 integerLog10 + 1000 integerLog10 + + 10000000000000000.0 log:10 + 10000000000000000 integerLog10 + 100000000000000000 integerLog10 + 1000000000000000000 integerLog10 + 10000000000000000000 integerLog10 + 100000000000000000000 integerLog10 + 1000000000000000000000 integerLog10 -> 21 + 1000000000000000000000000000000 integerLog10 -> 30 + 10000000000000000000000000000000000000000 integerLog10 -> 40 + + 1 to:10000 by:10 do:[:i | + self assert:(i factorial printString size == (i factorial integerLog10+1)) + ]. + 21 factorial printString size + 21 factorial integerLog10 + 51 factorial printString size + 51 factorial integerLog10 + " + + "Created: / 02-07-2017 / 01:20:49 / cg" + "Modified: / 02-07-2017 / 10:16:40 / cg" +! + integerLog2 "return the floor of log2 of the receiver. This is the same as (self log:2) floor." @@ -4177,6 +4212,12 @@ "print the receiver as a hex number on the standard output stream" (self printStringRadix:16) print + + " + 16rAFFE printStringRadix:16 + " + + "Modified (comment): / 02-07-2017 / 10:20:59 / cg" ! printOn:aStream base:base showRadix:showRadix