Skip to content

Instantly share code, notes, and snippets.

@polynomialspace
Created March 5, 2022 05:10
Show Gist options
  • Select an option

  • Save polynomialspace/4331e6be821abe0dc0fa2fb7ec4f4fcb to your computer and use it in GitHub Desktop.

Select an option

Save polynomialspace/4331e6be821abe0dc0fa2fb7ec4f4fcb to your computer and use it in GitHub Desktop.

Revisions

  1. polynomialspace created this gist Mar 5, 2022.
    29 changes: 29 additions & 0 deletions byteunits.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // You can edit this code!
    // Click here and start typing.
    package byteunits


    const (
    _ = iota
    KB = 1 << (10 * iota)
    MB
    GB
    TB
    PB
    EB
    //overflow
    // ZB
    // YB
    )

    const (
    SI_KB int = 1e3
    SI_MB int = 1e6
    SI_GB int = 1e9
    SI_TB int = 1e12
    SI_PB int = 1e15
    SI_EB int = 1e18
    //overflow
    // SI_ZB int = 1e21
    // SI_YB int = 1e24
    )