diff --git a/src/Codebelt.Unitify/BinaryPrefix.cs b/src/Codebelt.Unitify/BinaryPrefix.cs index 337e31a..18ad6b8 100644 --- a/src/Codebelt.Unitify/BinaryPrefix.cs +++ b/src/Codebelt.Unitify/BinaryPrefix.cs @@ -49,14 +49,16 @@ public static double ConvertBytesToBits(double bytes) { var list = new List() { - Exbi, - Gibi, Kibi, Mebi, - Pebi, + Gibi, Tebi, + Pebi, + Exbi, + Zebi, Yobi, - Zebi + Robi, + Quebi }; return list; }); @@ -110,9 +112,21 @@ public static double ConvertBytesToBits(double bytes) public static BinaryPrefix Yobi => new("yobi", "Yi", 80); /// - /// Gets the complete sequence of multiples binary prefixes as specified by Institute of Electrical and Electronics Engineers (IEEE). + /// Gets the binary-multiple prefix robi (symbol 'Ri'), 2^90 = 1237940039285380274899124224. + /// + /// The binary-multiple prefix robi (symbol 'Ri'). + public static BinaryPrefix Robi => new("robi", "Ri", 90); + + /// + /// Gets the binary-multiple prefix quebi (symbol 'Qi'), 2^100 = 1267650600228229401496703205376. + /// + /// The binary-multiple prefix quebi (symbol 'Qi'). + public static BinaryPrefix Quebi => new("quebi", "Qi", 100); + + /// + /// Gets the complete sequence of multiples binary prefixes as specified by IEC 80000-13:2025, covering kibi (2^10) through quebi (2^100). /// - /// The complete sequence of multiples binary prefixes as specified by Institute of Electrical and Electronics Engineers (IEEE). + /// The complete sequence of multiples binary prefixes as specified by IEC 80000-13:2025. public static IEnumerable BinaryPrefixes => LazyPrefixes.Value; /// diff --git a/src/Codebelt.Unitify/PrefixTableExtensions.cs b/src/Codebelt.Unitify/PrefixTableExtensions.cs index c18a771..c2a8e67 100644 --- a/src/Codebelt.Unitify/PrefixTableExtensions.cs +++ b/src/Codebelt.Unitify/PrefixTableExtensions.cs @@ -326,5 +326,25 @@ public static IPrefixUnit YobiOrDefault(this PrefixTable prefixes) { return prefixes.SingleOrDefault(p => p.Prefix.Symbol == BinaryPrefix.Yobi.Symbol); } + + /// + /// Returns the unit with the Robi prefix or the default value if not found. + /// + /// The table of multiple units. + /// The unit with the Robi prefix or the default value. + public static IPrefixUnit RobiOrDefault(this PrefixTable prefixes) + { + return prefixes.SingleOrDefault(p => p.Prefix.Symbol == BinaryPrefix.Robi.Symbol); + } + + /// + /// Returns the unit with the Quebi prefix or the default value if not found. + /// + /// The table of multiple units. + /// The unit with the Quebi prefix or the default value. + public static IPrefixUnit QuebiOrDefault(this PrefixTable prefixes) + { + return prefixes.SingleOrDefault(p => p.Prefix.Symbol == BinaryPrefix.Quebi.Symbol); + } } } diff --git a/test/Codebelt.Unitify/BinaryPrefixTest.cs b/test/Codebelt.Unitify/BinaryPrefixTest.cs index 8b2034e..4b8337e 100644 --- a/test/Codebelt.Unitify/BinaryPrefixTest.cs +++ b/test/Codebelt.Unitify/BinaryPrefixTest.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Codebelt.Extensions.Xunit; using Xunit; @@ -21,6 +22,25 @@ public void BinaryPrefix_ShouldVerifyMultiplePrefixConstants() Assert.Equal(BinaryPrefix.Exbi.Multiplier, Math.Pow(2, 60)); Assert.Equal(BinaryPrefix.Zebi.Multiplier, Math.Pow(2, 70)); Assert.Equal(BinaryPrefix.Yobi.Multiplier, Math.Pow(2, 80)); + Assert.Equal(BinaryPrefix.Robi.Multiplier, Math.Pow(2, 90)); + Assert.Equal(BinaryPrefix.Quebi.Multiplier, Math.Pow(2, 100)); + } + + [Fact] + public void BinaryPrefix_ShouldContainAllPrefixesInOrder() + { + var prefixes = BinaryPrefix.BinaryPrefixes.ToList(); + Assert.Equal(10, prefixes.Count); + Assert.Equal("Ki", prefixes[0].Symbol); + Assert.Equal("Mi", prefixes[1].Symbol); + Assert.Equal("Gi", prefixes[2].Symbol); + Assert.Equal("Ti", prefixes[3].Symbol); + Assert.Equal("Pi", prefixes[4].Symbol); + Assert.Equal("Ei", prefixes[5].Symbol); + Assert.Equal("Zi", prefixes[6].Symbol); + Assert.Equal("Yi", prefixes[7].Symbol); + Assert.Equal("Ri", prefixes[8].Symbol); + Assert.Equal("Qi", prefixes[9].Symbol); } } }