@@ -16,33 +16,37 @@ Storage units according to ISO IEC 80000-13:2008 implemented in Java.
1616* Lossless conversion between all units
1717* Human-readable text format, including custom formats
1818* Compatible with any ` java.lang.Number `
19- * Custom serializers for Jackson, MongoDB & EclipseLink
19+ * Custom serializers for Jackson, MongoDB, EclipseLink, and others
2020
2121### Available Units
2222
23- | Name | Symbol | Exponential | Absolute |
24- | ----------| --------| ---------------------| ----------------------------------------|
25- | Byte | B | 2<sup >0</sup > Byte | 1 Byte |
26- | Kibibyte | KiB | 2<sup >10</sup > Byte | 1 024 Byte |
27- | Mebibyte | MiB | 2<sup >20</sup > Byte | 1 048 576 Byte |
28- | Gibibyte | GiB | 2<sup >30</sup > Byte | 1 073 741 824 Byte |
29- | Tebibyte | TiB | 2<sup >40</sup > Byte | 1 099 511 627 776 Byte |
30- | Pebibyte | PiB | 2<sup >50</sup > Byte | 1 125 899 906 842 624 Byte |
31- | Exbibyte | EiB | 2<sup >60</sup > Byte | 1 152 921 504 606 846 976 Byte |
32- | Zebibyte | ZiB | 2<sup >70</sup > Byte | 1 180 591 620 717 411 303 424 Byte |
33- | Yobibyte | YiB | 2<sup >80</sup > Byte | 1 208 925 819 614 629 174 706 176 Byte |
34-
35- | Name | Symbol | Exponential | Absolute |
36- | -----------| --------| ----------------------| ----------------------------------------|
37- | Byte | B | 10<sup >0</sup > Byte | 1 Byte |
38- | Kilobyte | KB | 10<sup >3</sup > Byte | 1 000 Byte |
39- | Megabyte | MB | 10<sup >6</sup > Byte | 1 000 000 Byte |
40- | Gigabyte | GB | 10<sup >9</sup > Byte | 1 000 000 000 Byte |
41- | Terabyte | TB | 10<sup >12</sup > Byte | 1 000 000 000 000 Byte |
42- | Petabyte | PB | 10<sup >15</sup > Byte | 1 000 000 000 000 000 Byte |
43- | Exabyte | EB | 10<sup >18</sup > Byte | 1 000 000 000 000 000 000 Byte |
44- | Zettabyte | ZB | 10<sup >21</sup > Byte | 1 000 000 000 000 000 000 000 Byte |
45- | Yottabyte | YB | 10<sup >24</sup > Byte | 1 000 000 000 000 000 000 000 000 Byte |
23+ | Name | Symbol | Exponential | Absolute |
24+ | ----------| --------| ----------------------| ------------------------------------------------|
25+ | Byte | B | 2<sup >0</sup > Byte | 1 Byte |
26+ | Kibibyte | KiB | 2<sup >10</sup > Byte | 1 024 Byte |
27+ | Mebibyte | MiB | 2<sup >20</sup > Byte | 1 048 576 Byte |
28+ | Gibibyte | GiB | 2<sup >30</sup > Byte | 1 073 741 824 Byte |
29+ | Tebibyte | TiB | 2<sup >40</sup > Byte | 1 099 511 627 776 Byte |
30+ | Pebibyte | PiB | 2<sup >50</sup > Byte | 1 125 899 906 842 624 Byte |
31+ | Exbibyte | EiB | 2<sup >60</sup > Byte | 1 152 921 504 606 846 976 Byte |
32+ | Zebibyte | ZiB | 2<sup >70</sup > Byte | 1 180 591 620 717 411 303 424 Byte |
33+ | Yobibyte | YiB | 2<sup >80</sup > Byte | 1 208 925 819 614 629 174 706 176 Byte |
34+ | Robibyte | RiB | 2<sup >90</sup > Byte | 1 237 940 039 285 380 274 899 124 224 Byte |
35+ | Qubibyte | QiB | 2<sup >100</sup > Byte | 1 267 650 600 228 229 401 496 703 205 376 Byte |
36+
37+ | Name | Symbol | Exponential | Absolute |
38+ | ------------| --------| ----------------------| ------------------------------------------------|
39+ | Byte | B | 10<sup >0</sup > Byte | 1 Byte |
40+ | Kilobyte | KB | 10<sup >3</sup > Byte | 1 000 Byte |
41+ | Megabyte | MB | 10<sup >6</sup > Byte | 1 000 000 Byte |
42+ | Gigabyte | GB | 10<sup >9</sup > Byte | 1 000 000 000 Byte |
43+ | Terabyte | TB | 10<sup >12</sup > Byte | 1 000 000 000 000 Byte |
44+ | Petabyte | PB | 10<sup >15</sup > Byte | 1 000 000 000 000 000 Byte |
45+ | Exabyte | EB | 10<sup >18</sup > Byte | 1 000 000 000 000 000 000 Byte |
46+ | Zettabyte | ZB | 10<sup >21</sup > Byte | 1 000 000 000 000 000 000 000 Byte |
47+ | Yottabyte | YB | 10<sup >24</sup > Byte | 1 000 000 000 000 000 000 000 000 Byte |
48+ | Ronnabyte | RB | 10<sup >27</sup > Byte | 1 000 000 000 000 000 000 000 000 000 Byte |
49+ | Quettabyte | QB | 10<sup >30</sup > Byte | 1 000 000 000 000 000 000 000 000 000 000 Byte |
4650
4751## Usage
4852
@@ -52,18 +56,18 @@ Each unit implements a Byte-based static factory method (`valueOf(BigInteger)` o
5256
5357``` java
5458// 'long' based
55- Kilobyte unit = Kilobyte . valueOf(500 ) // 500 Byte or "0.50 kB"
56- Kibibyte unit = Kibibyte . valueOf(512 ) // 512 Byte or "0.50 KiB"
59+ Kilobyte unit = Kilobyte . valueOf(500 ) // 500 Byte or "0.50 kB"
60+ Kibibyte unit = Kibibyte . valueOf(512 ) // 512 Byte or "0.50 KiB"
5761
58- Megabyte unit = Megabyte . valueOf(1_000_000 ) // 1 000 000 Byte or "1.00 MB"
59- Mebibyte unit = Mebibyte . valueOf(1_048_576 ) // 1 048 576 Byte or "1.00 MiB"
62+ Megabyte unit = Megabyte . valueOf(1_000_000 ) // 1 000 000 Byte or "1.00 MB"
63+ Mebibyte unit = Mebibyte . valueOf(1_048_576 ) // 1 048 576 Byte or "1.00 MiB"
6064
6165// 'BigInteger' based
62- Kilobyte unit = Kilobyte . valueOf(BigInteger . valueOf(500 )) // 500 Byte or "0.50 kB"
63- Kibibyte unit = Kibibyte . valueOf(BigInteger . valueOf(512 )) // 512 Byte or "0.50 KiB"
66+ Kilobyte unit = Kilobyte . valueOf(BigInteger . valueOf(500 )) // 500 Byte or "0.50 kB"
67+ Kibibyte unit = Kibibyte . valueOf(BigInteger . valueOf(512 )) // 512 Byte or "0.50 KiB"
6468
65- Megabyte unit = Megabyte . valueOf(BigInteger . valueOf(1000000 )) // 1 000 000 Byte or "1.00 MB"
66- Mebibyte unit = Mebibyte . valueOf(BigInteger . valueOf(1_048_576 )) // 1 048 576 Byte or "1.00 MB"
69+ Megabyte unit = Megabyte . valueOf(BigInteger . valueOf(1000000 )) // 1 000 000 Byte or "1.00 MB"
70+ Mebibyte unit = Mebibyte . valueOf(BigInteger . valueOf(1_048_576 )) // 1 048 576 Byte or "1.00 MB"
6771```
6872
6973The ` StorageUnits ` class offers three factory methods that automatically pick the best-matching unit for a given number of bytes.
@@ -105,15 +109,19 @@ Pebibyte unit = pebibyte(1) // 1 125 899 906 842 624 Byte
105109Exbibyte unit = exbibyte(1 ) // 1 152 921 504 606 846 976 Byte
106110Zebibyte unit = zebibyte(1 ) // 1 180 591 620 717 411 303 424 Byte
107111Yobibyte unit = yobibyte(1 ) // 1 208 925 819 614 629 174 706 176 Byte
108-
109- Kilobyte unit = kilobyte(1 ) // 1 000 Byte
110- Megabyte unit = megabyte(1 ) // 1 000 000 Byte
111- Gigabyte unit = gigabyte(1 ) // 1 000 000 000 Byte
112- Terabyte unit = terabyte(1 ) // 1 000 000 000 000 Byte
113- Petabyte unit = petabyte(1 ) // 1 000 000 000 000 000 Byte
114- Exabyte unit = exabyte(1 ) // 1 000 000 000 000 000 000 Byte
115- Zettabyte unit = zettabyte(1 ) // 1 000 000 000 000 000 000 000 Byte
116- Yottabyte unit = yottabyte(1 ) // 1 000 000 000 000 000 000 000 000 Byte
112+ Robibyte unit = robibyte(1 ) // 1 237 940 039 285 380 274 899 124 224 Byte
113+ Qubibyte unit = qubibyte(1 ) // 1 267 650 600 228 229 401 496 703 205 376 Byte
114+
115+ Kilobyte unit = kilobyte(1 ) // 1 000 Byte
116+ Megabyte unit = megabyte(1 ) // 1 000 000 Byte
117+ Gigabyte unit = gigabyte(1 ) // 1 000 000 000 Byte
118+ Terabyte unit = terabyte(1 ) // 1 000 000 000 000 Byte
119+ Petabyte unit = petabyte(1 ) // 1 000 000 000 000 000 Byte
120+ Exabyte unit = exabyte(1 ) // 1 000 000 000 000 000 000 Byte
121+ Zettabyte unit = zettabyte(1 ) // 1 000 000 000 000 000 000 000 Byte
122+ Yottabyte unit = yottabyte(1 ) // 1 000 000 000 000 000 000 000 000 Byte
123+ Ronnabyte unit = ronnabyte(1 ) // 1 000 000 000 000 000 000 000 000 000 Byte
124+ Quettabyte unit = quettabyte(1 ) // 1 000 000 000 000 000 000 000 000 000 000 Byte
117125```
118126
119127### Add, Subtract, Multiply, Divide
0 commit comments