{"record":{"id":"ccaf2694ba8814da","repo":"Humanizr/Humanizer","slug":"eib-is-outside-the-range-supported-by-bytesize-bit","errorCode":null,"errorMessage":"EiB is outside the range supported by ByteSize.Bits.","messagePattern":"EiB is outside the range supported by ByteSize\\.Bits\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Bytes/ByteSize.cs","lineNumber":1034,"sourceCode":"    {\n        if (string.IsNullOrWhiteSpace(format) || format == \"G\")\n        {\n            return null;\n        }\n\n        var maskedFormat = MaskFormatLiterals(format!);\n        var incompatibleUnits = ReferenceEquals(units, DecimalUnits) ? BinaryUnits : DecimalUnits;\n        foreach (var unit in incompatibleUnits)\n        {\n            if (maskedFormat.Contains(unit.Symbol, StringComparison.OrdinalIgnoreCase))\n            {\n                throw new FormatException($\"Unit token '{unit.Symbol}' does not belong to the selected byte-size unit system.\");\n            }\n        }\n\n        if (maskedFormat.Contains(\"EiB\", StringComparison.OrdinalIgnoreCase))\n        {\n            throw new FormatException(\"EiB is outside the range supported by ByteSize.Bits.\");\n        }\n\n        SystemUnit? selectedUnit = null;\n        var remainingFormat = maskedFormat;\n        foreach (var unit in units)\n        {\n            if (!remainingFormat.Contains(unit.Symbol, StringComparison.OrdinalIgnoreCase))\n            {\n                continue;\n            }\n\n            if (selectedUnit is not null && selectedUnit.Value.DataUnit != unit.DataUnit)\n            {\n                throw new FormatException(\"A byte-size format can contain only one distinct unit token.\");\n            }\n\n            selectedUnit = unit;\n            remainingFormat = ReplaceOrdinalIgnoreCase(","sourceCodeStart":1016,"sourceCodeEnd":1052,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Bytes/ByteSize.cs#L1016-L1052","documentation":"Thrown by ByteSize.FindFormatUnit when the masked format contains the literal 'EiB'. The library cannot represent an exbibyte in its backed range (the supported ceiling is BytesInPebibyte*1024, one byte short of a full exbibyte of bits in a signed long), so the EiB token is rejected explicitly even though it belongs to the binary IEC family.","triggerScenarios":"Calling ToString(\"#.## EiB\", ...) on a ByteSize, or passing an IEC format string that includes the exbibyte token. The check is case-insensitive and runs after the incompatible-system scan.","commonSituations":"Generating format strings programmatically from a list of IEC units without filtering out EiB, or copy-pasting a max-capacity format from documentation that assumes exbibyte support exists.","solutions":["Drop the EiB token from the format string; the largest representable binary unit is PiB.","For values near one EiB, format in PiB (which will show ~1024 PiB) or switch to a custom ulong-bits representation.","Quote 'EiB' as a literal ('\"EiB\"') only if you want the letters as decoration, not as a unit token."],"exampleFix":"// before\nvar text = size.ToString(\"#.## EiB\");\n\n// after\nvar text = size.ToString(\"#.## PiB\"); // largest supported binary token","handlingStrategy":"validation","validationCode":"static string StripEib(string format) =>\n    format.Contains(\"EiB\", StringComparison.OrdinalIgnoreCase)\n        ? throw new ArgumentException(\"EiB is not supported; use PiB.\")\n        : format;","typeGuard":null,"tryCatchPattern":"try { return size.ToString(format); }\ncatch (FormatException) { throw new ArgumentException(\"EiB token is not supported by ByteSize.\", nameof(format)); }","preventionTips":["The largest supported binary token is PiB","Do not auto-generate IEC format strings from a full unit list","Quote 'EiB' if it must appear as decoration"],"tags":["bytesize","format-string","iec-units","range-limit"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}