units/byte_si.fz
# This file is part of the Fuzion language implementation.
#
# The Fuzion language implementation is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, version 3 of the License.
#
# The Fuzion language implementation is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License along with The
# Fuzion language implementation. If not, see <https://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------
#
# Tokiwa Software GmbH, Germany
#
# Source code of Fuzion standard library feature units.byte_si
#
# -----------------------------------------------------------------------
# units.byte_si -- unit type defining units used for units.data_size
#
# Uses SI prefixes (base 10), e.g. 1000 Byte = 1 kilobyte.
#
public byte_si(
# the next smaller unit, like kilobyte is smaller than megabyte, if it exists
public smaller Lazy (option byte_si),
# the next larger unit, like gigabyte is larger than megabyte, if it exists
public larger Lazy (option byte_si),
# the number of bytes in one of this unit
public in_bytes u128,
# a short name of at most three codepoints
public short_name String,
# a longer, but still short name of this unit
public name String) is
# byte unit
#
public type.b units.byte_si => units.byte_si nil kb 1.as_u128 "B" "byte"
# kilobyte unit
#
public type.kb units.byte_si => units.byte_si b mb 1E3.as_u128**1.as_u128 "kB" "kilobyte"
# megabyte unit
#
public type.mb units.byte_si => units.byte_si kb gb 1E3.as_u128**2.as_u128 "MB" "megabyte"
# gigabyte unit
#
public type.gb units.byte_si => units.byte_si mb tb 1E3.as_u128**3.as_u128 "GB" "gigabyte"
# terabyte unit
#
public type.tb units.byte_si => units.byte_si gb pb 1E3.as_u128**4.as_u128 "TB" "terabyte"
# petabyte unit
#
public type.pb units.byte_si => units.byte_si tb eb 1E3.as_u128**5.as_u128 "PB" "petabyte"
# exabyte unit
#
public type.eb units.byte_si => units.byte_si pb zb 1E3.as_u128**6.as_u128 "EB" "exabyte"
# zettabyte unit
#
public type.zb units.byte_si => units.byte_si eb yb 1E3.as_u128**7.as_u128 "ZB" "zettabyte"
# yottabyte unit
#
public type.yb units.byte_si => units.byte_si zb rb 1E3.as_u128**8.as_u128 "YB" "yottabyte"
# ronnabyte unit
#
public type.rb units.byte_si => units.byte_si yb qb 1E3.as_u128**9.as_u128 "RB" "ronnabyte"
# quettabyte unit
#
public type.qb units.byte_si => units.byte_si rb nil 1E3.as_u128**10.as_u128 "QB" "quettabyte"
last changed: 2026-02-23