-
Notifications
You must be signed in to change notification settings - Fork 22
/
volume.go
476 lines (391 loc) · 12.1 KB
/
volume.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
package unit
// Volume represents a volume in cubic meters
type Volume Unit
// ...
const (
// SI
CubicYoctometer = CubicMeter * 1e-72
CubicZeptometer = CubicMeter * 1e-63
CubicAttometer = CubicMeter * 1e-54
CubicFemtometer = CubicMeter * 1e-45
CubicPicometer = CubicMeter * 1e-36
CubicNanometer = CubicMeter * 1e-27
CubicMicrometer = CubicMeter * 1e-18
CubicMillimeter = CubicMeter * 1e-9
CubicCentimeter = CubicMeter * 1e-6
CubicDecimeter = CubicMeter * 1e-3
CubicMeter Volume = 1e0
CubicDecameter = CubicMeter * 1e3
CubicHectometer = CubicMeter * 1e6
CubicKilometer = CubicMeter * 1e9
CubicMegameter = CubicMeter * 1e18
CubicGigameter = CubicMeter * 1e27
CubicTerameter = CubicMeter * 1e36
CubicPetameter = CubicMeter * 1e45
CubicExameter = CubicMeter * 1e54
CubicZettameter = CubicMeter * 1e63
CubicYottameter = CubicMeter * 1e72
// SI derived
Yoctoliter = Liter * 1e-24
Zepoliter = Liter * 1e-21
Attoliter = Liter * 1e-18
Femtoliter = Liter * 1e-15
Picoliter = Liter * 1e-12
Nanoliter = Liter * 1e-9
Microliter = Liter * 1e-6
Milliliter = Liter * 1e-3
Centiliter = Liter * 1e-2
Deciliter = Liter * 1e-1
Liter = CubicMeter * 1e-3
Decaliter = Liter * 1e1
Hectoliter = Liter * 1e2
Kiloliter = Liter * 1e3
Megaliter = Liter * 1e6
Gigaliter = Liter * 1e9
Teraliter = Liter * 1e12
Petaliter = Liter * 1e15
Exaliter = Liter * 1e18
Zettaliter = Liter * 1e21
Yottaliter = Liter * 1e24
// US
CubicInch = Liter * 0.016387064
CubicFoot = CubicInch * 1728
CubicYard = CubicFoot * 27
CubicMile = CubicYard * 5451776000
CubicFurlong = CubicMile * 0.00195314
// imperial liquid
ImperialGallon = Liter * 4.54609
ImperialQuart = ImperialGallon / 4
ImperialPint = ImperialQuart / 2
ImperialCup = ImperialPint / 2
ImperialGill = ImperialPint / 4
ImperialFluidOunce = ImperialGill / 5
ImperialFluidDram = ImperialFluidOunce / 8
ImperialPeck = ImperialGallon * 2
ImperialBushel = ImperialPeck * 4
// metric cooking
MetricTableSpoon = Milliliter * 15
MetricTeaSpoon = Milliliter * 5
// US liquid
USLiquidGallon = CubicInch * 231
USLiquidQuart = CubicInch * 57.75
USLiquidPint = CubicInch * 28.875
USCup = USLiquidPint / 2
USLegalCup = Milliliter * 240
USGill = Milliliter * 118.29411825
USFluidDram = USFluidOunce / 8
USFluidOunce = USLiquidGallon / 128
USTableSpoon = USFluidOunce / 2
USTeaSpoon = USTableSpoon / 3
// US dry
USDryQuart = USDryGallon / 4
USBushel = USPeck * 4
USPeck = USDryGallon * 2
USDryGallon = CubicInch * 268.8025
USDryPint = CubicInch * 33.6003125
// misc
AustralianTableSpoon = Milliliter * 20
// aliases
ImperialTableSpoon = MetricTableSpoon
ImperialTeaSpoon = MetricTeaSpoon
)
// Yoctoliters returns the volume in yl
func (v Volume) Yoctoliters() float64 {
return float64(v / Yoctoliter)
}
// Zepoliters returns the volume in zl
func (v Volume) Zepoliters() float64 {
return float64(v / Zepoliter)
}
// Attoliters returns the volume in al
func (v Volume) Attoliters() float64 {
return float64(v / Attoliter)
}
// Femtoliters returns the volume in fl
func (v Volume) Femtoliters() float64 {
return float64(v / Femtoliter)
}
// Picoliters returns the volume in pl
func (v Volume) Picoliters() float64 {
return float64(v / Picoliter)
}
// Nanoliters returns the volume in nl
func (v Volume) Nanoliters() float64 {
return float64(v / Nanoliter)
}
// Microliters returns the volume in µl
func (v Volume) Microliters() float64 {
return float64(v / Microliter)
}
// Milliliters returns the volume in ml
func (v Volume) Milliliters() float64 {
return float64(v / Milliliter)
}
// Centiliters returns the volume in cl
func (v Volume) Centiliters() float64 {
return float64(v / Centiliter)
}
// Deciliters returns the volume in dl
func (v Volume) Deciliters() float64 {
return float64(v / Deciliter)
}
// Liters returns the volume in l
func (v Volume) Liters() float64 {
return float64(v / Liter)
}
// Decaliters returns the volume in Dl
func (v Volume) Decaliters() float64 {
return float64(v / Decaliter)
}
// Hectoliters returns the volume in Hl
func (v Volume) Hectoliters() float64 {
return float64(v / Hectoliter)
}
// Kiloliters returns the volume in Kl
func (v Volume) Kiloliters() float64 {
return float64(v / Kiloliter)
}
// Megaliters returns the volume in Ml
func (v Volume) Megaliters() float64 {
return float64(v / Megaliter)
}
// Gigaliters returns the volume in Gl
func (v Volume) Gigaliters() float64 {
return float64(v / Gigaliter)
}
// Teraliters returns the volume in Tl
func (v Volume) Teraliters() float64 {
return float64(v / Teraliter)
}
// Petaliters returns the volume in Pl
func (v Volume) Petaliters() float64 {
return float64(v / Petaliter)
}
// Exaliters returns the volume in El
func (v Volume) Exaliters() float64 {
return float64(v / Exaliter)
}
// Zettaliters returns the volume in Zl
func (v Volume) Zettaliters() float64 {
return float64(v / Zettaliter)
}
// CubicYoctometers returns the volume in ym³
func (v Volume) CubicYoctometers() float64 {
return float64(v / CubicYoctometer)
}
// CubicZeptometers returns the volume in zm³
func (v Volume) CubicZeptometers() float64 {
return float64(v / CubicZeptometer)
}
// CubicAttometers returns the volume in am³
func (v Volume) CubicAttometers() float64 {
return float64(v / CubicAttometer)
}
// CubicFemtometers returns the volume in fm³
func (v Volume) CubicFemtometers() float64 {
return float64(v / CubicFemtometer)
}
// CubicPicometers returns the volume in pm³
func (v Volume) CubicPicometers() float64 {
return float64(v / CubicPicometer)
}
// CubicNanometers returns the volume in nm³
func (v Volume) CubicNanometers() float64 {
return float64(v / CubicNanometer)
}
// CubicMicrometers returns the volume in µm³
func (v Volume) CubicMicrometers() float64 {
return float64(v / CubicMicrometer)
}
// CubicMillimeters returns the volume in mm³
func (v Volume) CubicMillimeters() float64 {
return float64(v / CubicMillimeter)
}
// CubicCentimeters returns the volume in cm³
func (v Volume) CubicCentimeters() float64 {
return float64(v / CubicCentimeter)
}
// CubicDecimeters returns the volume in dm³
func (v Volume) CubicDecimeters() float64 {
return float64(v / CubicDecimeter)
}
// CubicMeters returns the volume in m³
func (v Volume) CubicMeters() float64 {
return float64(v / CubicMeter)
}
// CubicDecameters returns the volume in dam³
func (v Volume) CubicDecameters() float64 {
return float64(v / CubicDecameter)
}
// CubicHectometers returns the volume in hm³
func (v Volume) CubicHectometers() float64 {
return float64(v / CubicHectometer)
}
// CubicKilometers returns the volume in km³
func (v Volume) CubicKilometers() float64 {
return float64(v / CubicKilometer)
}
// CubicMegameters returns the volume in Mm³
func (v Volume) CubicMegameters() float64 {
return float64(v / CubicMegameter)
}
// CubicGigameters returns the volume in Gm³
func (v Volume) CubicGigameters() float64 {
return float64(v / CubicGigameter)
}
// CubicTerameters returns the volume in Tm³
func (v Volume) CubicTerameters() float64 {
return float64(v / CubicTerameter)
}
// CubicPetameters returns the volume in Pm³
func (v Volume) CubicPetameters() float64 {
return float64(v / CubicPetameter)
}
// CubicExameters returns the volume in Em³
func (v Volume) CubicExameters() float64 {
return float64(v / CubicExameter)
}
// CubicZettameters returns the volume in Zm³
func (v Volume) CubicZettameters() float64 {
return float64(v / CubicZettameter)
}
// CubicYottameters returns the volume in Ym³
func (v Volume) CubicYottameters() float64 {
return float64(v / CubicYottameter)
}
// CubicInches returns the volume in in³
func (v Volume) CubicInches() float64 {
return float64(v / CubicInch)
}
// CubicFeet returns the volume in ft³
func (v Volume) CubicFeet() float64 {
return float64(v / CubicFoot)
}
// CubicYards returns the volume in yd³
func (v Volume) CubicYards() float64 {
return float64(v / CubicYard)
}
// CubicMiles returns the volume in mi³
func (v Volume) CubicMiles() float64 {
return float64(v / CubicMile)
}
// CubicFurlongs returns the volume in furlong³
func (v Volume) CubicFurlongs() float64 {
return float64(v / CubicFurlong)
}
// ImperialGallons returns the volume in imperial gallons
func (v Volume) ImperialGallons() float64 {
return float64(v / ImperialGallon)
}
// ImperialQuarts returns the volume in imperial quarts
func (v Volume) ImperialQuarts() float64 {
return float64(v / ImperialQuart)
}
// ImperialPints returns the volume in imperial pints
func (v Volume) ImperialPints() float64 {
return float64(v / ImperialPint)
}
// ImperialGills returns the volume in imperial gills
func (v Volume) ImperialGills() float64 {
return float64(v / ImperialGill)
}
// ImperialCups returns the volume in imperial cups
func (v Volume) ImperialCups() float64 {
return float64(v / ImperialCup)
}
// ImperialFluidOunces returns the volume in imperial fluid ounces
func (v Volume) ImperialFluidOunces() float64 {
return float64(v / ImperialFluidOunce)
}
// ImperialFluidDrams returns the volume in imperial fluid drams
func (v Volume) ImperialFluidDrams() float64 {
return float64(v / ImperialFluidDram)
}
// ImperialPecks returns the volume in imperial pecks
func (v Volume) ImperialPecks() float64 {
return float64(v / ImperialPeck)
}
// ImperialBushels returns the volume in imperial bushels
func (v Volume) ImperialBushels() float64 {
return float64(v / ImperialBushel)
}
// MetricTableSpoons returns the volume in metric/imperial tablespoons
func (v Volume) MetricTableSpoons() float64 {
return float64(v / MetricTableSpoon)
}
// MetricTeaSpoons returns the volume in metric/imperial teaspoons
func (v Volume) MetricTeaSpoons() float64 {
return float64(v / MetricTeaSpoon)
}
// ImperialTableSpoons returns the volume in metric/imperial tablespoons
func (v Volume) ImperialTableSpoons() float64 {
return v.MetricTableSpoons()
}
// ImperialTeaSpoons returns the volume in metric/imperial teaspoons
func (v Volume) ImperialTeaSpoons() float64 {
return v.MetricTeaSpoons()
}
// AustralianTableSpoons returns the volume in Australian tablespoons
func (v Volume) AustralianTableSpoons() float64 {
return float64(v / AustralianTableSpoon)
}
// USLiquidGallons returns the volume in US liquid gallons
func (v Volume) USLiquidGallons() float64 {
return float64(v / USLiquidGallon)
}
// USLiquidQuarts returns the volume in US liquid quarts
func (v Volume) USLiquidQuarts() float64 {
return float64(v / USLiquidQuart)
}
// USLiquidPints returns the volume in US liquid pints
func (v Volume) USLiquidPints() float64 {
return float64(v / USLiquidPint)
}
// USCups returns the volume in US cups
func (v Volume) USCups() float64 {
return float64(v / USCup)
}
// USLegalCups returns the volume in US legal cups
func (v Volume) USLegalCups() float64 {
return float64(v / USLegalCup)
}
// USGills returns the volume in US gills
func (v Volume) USGills() float64 {
return float64(v / USGill)
}
// USTableSpoons returns the volume in US table spoons
func (v Volume) USTableSpoons() float64 {
return float64(v / USTableSpoon)
}
// USTeaSpoons returns the volume in US tea spoons
func (v Volume) USTeaSpoons() float64 {
return float64(v / USTeaSpoon)
}
// USFluidDrams returns the volume in US fluid drams
func (v Volume) USFluidDrams() float64 {
return float64(v / USFluidDram)
}
// USFluidOunces returns the volume in US fluid ounces
func (v Volume) USFluidOunces() float64 {
return float64(v / USFluidOunce)
}
// USDryQuarts returns the volume in US dry quarts
func (v Volume) USDryQuarts() float64 {
return float64(v / USDryQuart)
}
// USBushels returns the volume in US bushels
func (v Volume) USBushels() float64 {
return float64(v / USBushel)
}
// USPecks returns the volume in US pecks
func (v Volume) USPecks() float64 {
return float64(v / USPeck)
}
// USDryGallons returns the volume in US dry gallons
func (v Volume) USDryGallons() float64 {
return float64(v / USDryGallon)
}
// USDryPints returns the volume in US dry pints
func (v Volume) USDryPints() float64 {
return float64(v / USDryPint)
}