-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnames_numbers_mappings.go
98 lines (92 loc) · 1.7 KB
/
names_numbers_mappings.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package humannumbers
var base = map[string]int{
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9,
"ten": 10,
"eleven": 11,
"twelve": 12,
"thirteen": 13,
"fourteen": 14,
"fifteen": 15,
"sixteen": 16,
"seventeen": 17,
"eightteen": 18,
"nineteen": 19,
}
var baseReverse = map[int]string{
0: "zero",
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
7: "seven",
8: "eight",
9: "nine",
10: "ten",
11: "eleven",
12: "twelve",
13: "thirteen",
14: "fourteen",
15: "fifteen",
16: "sixteen",
17: "seventeen",
18: "eightteen",
19: "nineteen",
}
var decades = map[string]int{
"twenty": 20,
"thirty": 30,
"forty": 40,
"fifty": 50,
"sixty": 60,
"seventy": 70,
"eighty": 80,
"ninety": 90,
}
var decadesReverse = map[int]string{
20: "twenty",
30: "thirty",
40: "forty",
50: "fifty",
60: "sixty",
70: "seventy",
80: "eighty",
90: "ninety",
}
var largeMagnitudes = map[string]int{
"thousand": 1000,
"million": 1e6,
"billion": 1e9,
"trillion": 1e12,
"quadrillion": 1e15,
"quintillion": 1e18,
}
// largeMagToString is a convience func to work the above map
// maybe we no longer need the map?
func largeMagToString(number int) string {
switch {
case number >= 100 && number < 1000:
return "hundred"
case number >= 1000 && number < 1e6:
return "thousand"
case number >= 1e6 && number < 1e9:
return "million"
case number >= 1e9 && number < 1e12:
return "billion"
case number >= 1e12 && number < 1e15:
return "trillion"
case number >= 1e15 && number < 1e18:
return "quadrillion"
}
return ""
}