forked from GsDevKit/NeoJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecimalDigitLength.st
More file actions
37 lines (36 loc) · 1.24 KB
/
decimalDigitLength.st
File metadata and controls
37 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
*neo-json-gemstone-core
decimalDigitLength
"Answer the number of digits printed out in base 10.
Note that this only works for positive SmallIntegers up to 64-bits."
"1 decimalDigitLength >>> 1"
"100000000 decimalDigitLength >>> 9"
"SmallInteger maxVal decimalDigitLength >>> 19"
^self < 10000
ifTrue:
[self < 100
ifTrue:
[self < 10 ifTrue: [1] ifFalse: [2]]
ifFalse:
[self < 1000 ifTrue: [3] ifFalse: [4]]]
ifFalse:
[self < 100000000
ifTrue:
[self < 1000000
ifTrue: [self < 100000 ifTrue: [5] ifFalse: [6]]
ifFalse: [self < 10000000 ifTrue: [7] ifFalse: [8]]]
ifFalse:
[self < 1000000000000
ifTrue:
[self < 10000000000
ifTrue: [self < 1000000000 ifTrue: [9] ifFalse: [10]]
ifFalse: [self < 100000000000 ifTrue: [11] ifFalse: [12]]]
ifFalse:
[self < 10000000000000000
ifTrue:
[self < 100000000000000
ifTrue: [self < 10000000000000 ifTrue: [13] ifFalse: [14]]
ifFalse: [self < 1000000000000000 ifTrue: [15] ifFalse: [16]]]
ifFalse:
[self < 1000000000000000000
ifTrue: [self < 100000000000000000 ifTrue: [17] ifFalse: [18]]
ifFalse: [self < 10000000000000000000 ifTrue: [19] ifFalse: [20]]]]]]