Skip to content

Commit 49d25a6

Browse files
committed
add some new SI prefixes that was standardized in November (ronna, quetta), source https://www.bipm.org/documents/20126/64811223/Resolutions-2022.pdf page 'Resolution 3'
1 parent f7b595b commit 49d25a6

File tree

3 files changed

+88
-40
lines changed

3 files changed

+88
-40
lines changed

datasize.go

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,29 @@ type Datasize Unit
66
// ...
77
const (
88
// base 10 (SI prefixes)
9-
Bit Datasize = 1e0
10-
Kilobit = Bit * 1e3
11-
Megabit = Bit * 1e6
12-
Gigabit = Bit * 1e9
13-
Terabit = Bit * 1e12
14-
Petabit = Bit * 1e15
15-
Exabit = Bit * 1e18
16-
Zettabit = Bit * 1e21
17-
Yottabit = Bit * 1e24
18-
19-
Byte = Bit * 8
20-
Kilobyte = Byte * 1e3
21-
Megabyte = Byte * 1e6
22-
Gigabyte = Byte * 1e9
23-
Terabyte = Byte * 1e12
24-
Petabyte = Byte * 1e15
25-
Exabyte = Byte * 1e18
26-
Zettabyte = Byte * 1e21
27-
Yottabyte = Byte * 1e24
9+
Bit Datasize = 1e0
10+
Kilobit = Bit * 1e3
11+
Megabit = Bit * 1e6
12+
Gigabit = Bit * 1e9
13+
Terabit = Bit * 1e12
14+
Petabit = Bit * 1e15
15+
Exabit = Bit * 1e18
16+
Zettabit = Bit * 1e21
17+
Yottabit = Bit * 1e24
18+
Ronnabit = Bit * 1e27
19+
Quettabit = Bit * 1e30
20+
21+
Byte = Bit * 8
22+
Kilobyte = Byte * 1e3
23+
Megabyte = Byte * 1e6
24+
Gigabyte = Byte * 1e9
25+
Terabyte = Byte * 1e12
26+
Petabyte = Byte * 1e15
27+
Exabyte = Byte * 1e18
28+
Zettabyte = Byte * 1e21
29+
Yottabyte = Byte * 1e24
30+
Ronnabyte = Byte * 1e27
31+
Quettabyte = Byte * 1e30
2832

2933
// base 2 (IEC prefixes)
3034
Kibibit = Bit * 1024
@@ -91,6 +95,16 @@ func (b Datasize) Yottabits() float64 {
9195
return float64(b / Yottabit)
9296
}
9397

98+
// Ronnabits returns the datasize in Rbit
99+
func (b Datasize) Ronnabits() float64 {
100+
return float64(b / Ronnabit)
101+
}
102+
103+
// Quettabits returns the datasize in Qbit
104+
func (b Datasize) Quettabits() float64 {
105+
return float64(b / Quettabit)
106+
}
107+
94108
// Bytes returns the datasize in B
95109
func (b Datasize) Bytes() float64 {
96110
return float64(b / Byte)
@@ -136,6 +150,16 @@ func (b Datasize) Yottabytes() float64 {
136150
return float64(b / Yottabyte)
137151
}
138152

153+
// Ronnabytes returns the datasize in RB
154+
func (b Datasize) Ronnabytes() float64 {
155+
return float64(b / Ronnabyte)
156+
}
157+
158+
// Quettabytes returns the datasize in RB
159+
func (b Datasize) Quettabytes() float64 {
160+
return float64(b / Quettabyte)
161+
}
162+
139163
// Kibibits returns the datasize in Kibit
140164
func (b Datasize) Kibibits() float64 {
141165
return float64(b / Kibibit)

length.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const (
2828
Exameter = Meter * 1e18
2929
Zettameter = Meter * 1e21
3030
Yottameter = Meter * 1e24
31+
Ronnameter = Meter * 1e27
32+
Quettameter = Meter * 1e30
3133

3234
// US
3335
Inch = Meter * 0.0254
@@ -164,6 +166,16 @@ func (l Length) Yottameters() float64 {
164166
return float64(l / Yottameter)
165167
}
166168

169+
// Ronnameters returns the length in in Rm
170+
func (l Length) Ronnameters() float64 {
171+
return float64(l / Ronnameter)
172+
}
173+
174+
// Quettameters returns the length in in Qm
175+
func (l Length) Quettameters() float64 {
176+
return float64(l / Quettameter)
177+
}
178+
167179
// Inches returns the length in in
168180
func (l Length) Inches() float64 {
169181
return float64(l / Inch)

mass.go

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,29 @@ type Mass Unit
66
// ...
77
const (
88
// SI
9-
Yoctogram = Gram * 1e-24
10-
Zeptogram = Gram * 1e-21
11-
Attogram = Gram * 1e-18
12-
Femtogram = Gram * 1e-15
13-
Picogram = Gram * 1e-12
14-
Nanogram = Gram * 1e-9
15-
Microgram = Gram * 1e-6
16-
Milligram = Gram * 1e-3
17-
Centigram = Gram * 1e-2
18-
Decigram = Gram * 1e-1
19-
Gram = Kilogram * 1e-3
20-
Decagram = Gram * 1e1
21-
Hectogram = Gram * 1e2
22-
Kilogram Mass = 1e0
23-
Megagram = Gram * 1e6
24-
Gigagram = Gram * 1e9
25-
Teragram = Gram * 1e12
26-
Petagram = Gram * 1e15
27-
Exagram = Gram * 1e18
28-
Zettagram = Gram * 1e21
29-
Yottagram = Gram * 1e24
9+
Yoctogram = Gram * 1e-24
10+
Zeptogram = Gram * 1e-21
11+
Attogram = Gram * 1e-18
12+
Femtogram = Gram * 1e-15
13+
Picogram = Gram * 1e-12
14+
Nanogram = Gram * 1e-9
15+
Microgram = Gram * 1e-6
16+
Milligram = Gram * 1e-3
17+
Centigram = Gram * 1e-2
18+
Decigram = Gram * 1e-1
19+
Gram = Kilogram * 1e-3
20+
Decagram = Gram * 1e1
21+
Hectogram = Gram * 1e2
22+
Kilogram Mass = 1e0
23+
Megagram = Gram * 1e6
24+
Gigagram = Gram * 1e9
25+
Teragram = Gram * 1e12
26+
Petagram = Gram * 1e15
27+
Exagram = Gram * 1e18
28+
Zettagram = Gram * 1e21
29+
Yottagram = Gram * 1e24
30+
Ronnagram = Gram * 1e27
31+
Quettagram = Gram * 1e30
3032

3133
// non-SI
3234
Tonne = Megagram
@@ -163,6 +165,16 @@ func (m Mass) Yottagrams() float64 {
163165
return float64(m / Yottagram)
164166
}
165167

168+
// Ronnagrams returns the mass in Rg
169+
func (m Mass) Ronnagrams() float64 {
170+
return float64(m / Ronnagram)
171+
}
172+
173+
// Quettagrams returns the mass in Qg
174+
func (m Mass) Quettagrams() float64 {
175+
return float64(m / Quettagram)
176+
}
177+
166178
// Tonnes returns the mass in t
167179
func (m Mass) Tonnes() float64 {
168180
return float64(m / Tonne)

0 commit comments

Comments
 (0)