Skip to content

crhumanize: add ParseIEC variants - #30

Merged
RaduBerinde merged 1 commit into
cockroachdb:mainfrom
RaduBerinde:crhumanize-parse-iec
Aug 23, 2026
Merged

crhumanize: add ParseIEC variants#30
RaduBerinde merged 1 commit into
cockroachdb:mainfrom
RaduBerinde:crhumanize-parse-iec

Conversation

@RaduBerinde

@RaduBerinde RaduBerinde commented Aug 23, 2026

Copy link
Copy Markdown
Member
  • Add ParseIEC, ParseBytesIEC, and ParseBytesPerSecIEC, which
    interpret unit prefixes as IEC (1024-based) units whether or not they
    carry the i indicator (e.g. both 1 KB and 1 KiB are 1,024). These
    can parse anything produced by Format with IEC units, including when
    the OmitI flag strips the i.
  • Allow Exact and OmitI to be used together; the combination used to
    panic, but the result now roundtrips exactly through the ParseIEC
    variants.
  • Add a test for the correspondence between the SI and IEC tables,
    which parseUnit now relies on.

Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com


This change is Reviewable

- Add `ParseIEC`, `ParseBytesIEC`, and `ParseBytesPerSecIEC`, which
  interpret unit prefixes as IEC (1024-based) units whether or not they
  carry the `i` indicator (e.g. both `1 KB` and `1 KiB` are 1,024). These
  can parse anything produced by `Format` with IEC units, including when
  the `OmitI` flag strips the `i`.
- Allow `Exact` and `OmitI` to be used together; the combination used to
  panic, but the result now roundtrips exactly through the `ParseIEC`
  variants.
- Add a test for the correspondence between the `SI` and `IEC` tables,
  which `parseUnit` now relies on.

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@RaduBerinde
RaduBerinde force-pushed the crhumanize-parse-iec branch from 349ad0d to ebb91ea Compare August 23, 2026 16:26
@RaduBerinde
RaduBerinde merged commit 44ef894 into cockroachdb:main Aug 23, 2026
9 checks passed
@RaduBerinde
RaduBerinde deleted the crhumanize-parse-iec branch August 23, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant