Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

data_size

units.data_size

units.data_size -- value representing a data_size in bytes

Note - The maximum representable value is 340,282,366 QB or 268,435,455 QiB,
due to using u128 internally.

Fields

The number of bytes in this data_size

Functions

 => 
String
[Redefinition of  Any.as_string]
Create a string representation of this units.data_size. The string representation
is not accurate, it is either an integer in the range [100,1023],
a float in the range [10,100) with exactly one fractional digit
or a float in the range [1,10) with exactly two fractional digit
both are followed by a byte_iec (base 2) string.

redefines:

Create a string representation of this units.data_size using the given unit
Output fo as_string padded for nice alignment in a table, e.g.
' 1 B '
'12.3 KiB'
' 500 MiB'
Create a string representation of this units.data_size using the given unit
The result is padded for alignment in a table, e.g.
' 1 B '
'1023 GiB'
'1.42 kB '
Create a string representation of this units.data_size. The string representation
is not accurate, it is either an integer in the range [10,999],
a float in the range [10,100) with exactly one fractional digit
or a float in the range [1,10) with exactly two fractional digit
both are followed by a byte_si (base 10) string.
Output fo as_string_si padded for nice alignment in a table, e.g.
' 1 B '
'12.3 kB'
' 500 MB'
(R 
type
, F 
type
: Typed_Function R, f F)
 => 
R
[Inherited from  Any]
dynamic_apply -- apply `f.call` to `Any.this`'s dynamic type and value

This can be used to perform operation on values depending on their dynamic
type.

Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:


NYI: ENHANCEMENT: #5892: If this is fixed, we could write

 => 
Type
[Inherited from  Any]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.

There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
this units.data_size in exabytes (10**18 bytes), omitting fractional part
this units.data_size in exabytes (10**18 bytes), including fractional part
this units.data_size in exbibytes (1024**6 bytes), omitting fractional part
this units.data_size in exbibytes (1024**6 bytes), including fractional part
this units.data_size in gigabytes (10**9 bytes), omitting fractional part
this units.data_size in gigabytes (10**9 bytes), including fractional part
this units.data_size in gibibytes (1024**3 bytes), omitting fractional part
this units.data_size in gibibytes (1024**3 bytes), including fractional part
this units.data_size multiplied by factor n
this units.data_size and another one combined
this units.data_size minus another units.data_size
this units.data_size divided by units.data_size other, rounding down
this units.data_size in kilobytes (10**3 bytes), omitting fractional part
this units.data_size in kilobytes (10**3 bytes), including fractional part
this units.data_size in kibibytes (1024**1 bytes), omitting fractional part
this units.data_size in kibibytes (1024**1 bytes), including fractional part
this units.data_size in megabytes (10**6 bytes), omitting fractional part
this units.data_size in megabytes (10**6 bytes), including fractional part
this units.data_size in mebibytes (1024**2 bytes), omitting fractional part
this units.data_size in mebibytes (1024**2 bytes), including fractional part
this units.data_size in petabytes (10**15 bytes), omitting fractional part
this units.data_size in petabytes (10**15 bytes), including fractional part
this units.data_size in pebibytes (1024**5 bytes), omitting fractional part
this units.data_size in pebibytes (1024**5 bytes), including fractional part
 => 
String
[Inherited from  Any]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
this units.data_size in quettabytes (10**30 bytes), omitting fractional part
this units.data_size in quettabytes (10**30 bytes), including fractional part
this units.data_size in quebibytes (1024**10 bytes), omitting fractional part
this units.data_size in quebibytes (1024**10 bytes), including fractional part
this units.data_size in ronnabytes (10**27 bytes), omitting fractional part
this units.data_size in ronnabytes (10**37 bytes), including fractional part
this units.data_size in robibytes (1024**9 bytes), omitting fractional part
this units.data_size in robibytes (1024**9 bytes), including fractional part
Scales this data size by a floating-point factor.

This operation is approximate:
- The factor is a floating-point value and may be imprecise.
- Fractional bytes are not representable and will be rounded.
- Large values may not be exactly representable in a float and are
therefore approximated before conversion back to bytes.

Use the `infix *` for exact, byte-precise scaling with integers.
this units.data_size in terabytes (10**12 bytes), omitting fractional part
this units.data_size in terabytes (10**12 bytes), including fractional part
this units.data_size in tebibytes (1024**4 bytes), omitting fractional part
this units.data_size in tebibytes (1024**4 bytes), including fractional part
Determines the iec unit to use for as_string,
such that the resulting value is in the range [1,1024)
Determines the si prefixed unit to use for as_string,
such that the resulting value is is in the range [1,1000)
this units.data_size in yottabytes (10**24 bytes), omitting fractional part
this units.data_size in yottabytes (10**24 bytes), including fractional part
this units.data_size in yobibytes (1024**8 bytes), omitting fractional part
this units.data_size in yobibytes (1024**8 bytes), including fractional part
this units.data_size in zettabytes (10**21 bytes), omitting fractional part
this units.data_size in zettabytes (10**21 bytes), including fractional part
this units.data_size in zebibytes (1024**7 bytes), omitting fractional part
this units.data_size in zebibytes (1024**7 bytes), including fractional part

Type Functions

 => 
String
[Inherited from  Type]
string representation of this type to be used for debugging.

result has the form "Type of '<name>'", but this might change in the future

redefines:

create units.data_size of n bytes

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
 => 
Type
[Inherited from  Type]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.

redefines:

create units.data_size of n exabytes (10**18 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n exbibytes (1024**6 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
(a property.orderable.this.type, b property.orderable.this.type)
 => 
bool
[Inherited from  orderable]
equality implements the default equality relation for values of this type.

This relation must be

- reflexive (equality a a),
- symmetric (equality a b = equality b a), and
- transitive ((equality a b && equality b c) : equality a c).

result is true iff 'a' is considered to represent the same abstract value
as 'b'.
create units.data_size of n gigabytes (10**9 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n gibibytes (1024**3 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
(d units.data_size.this.type)
 => 
u64
create hash code from a units.data_size
(T 
type
)
 => 
bool
[Inherited from  Type]
Is this type assignable to a type parameter with constraint `T`?

The result of this is a compile-time constant that can be used to specialize
code for a particular type.


it is most useful in conjunction with preconditions or `if` statements as in


or

create units.data_size of n kilobytes (10**3 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n kibibytes (1024**1 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
total order
the maximum units.data_size
max value for a units.data_size given in bytes
max value for a units.data_size given in exabytes (10**18 bytes)
max value for a units.data_size given in exbibytes (1024**6 bytes)
max value for a units.data_size given in gibibytes (1024**3 bytes)
max value for a units.data_size given in gigabytes (10**9 bytes)
max value for a units.data_size given in kibibytes (1024**1 bytes)
max value for a units.data_size given in kilobytes (10**3 bytes)
max value for a units.data_size given in mebibytes (1024**2 bytes)
max value for a units.data_size given in megabytes (10**6 bytes)
max value for a units.data_size given in pebibytes (1024**5 bytes)
max value for a units.data_size given in petabytes (10**15 bytes)
max value for a units.data_size given in quebibytes (1024**10 bytes)
max value for a units.data_size given in quettabytes (10**30 bytes)
max value for a units.data_size given in robibytes (1024**9 bytes)
max value for a units.data_size given in ronnabytes (10**27 bytes)
max value for a units.data_size given in tebibytes (1024**4 bytes)
max value for a units.data_size given in terabytes (10**12 bytes)
max value for a units.data_size given in yobibytes (1024**8 bytes)
max value for a units.data_size given in yottabytes (10**24 bytes)
max value for a units.data_size given in zebibytes (1024**7 bytes)
max value for a units.data_size given in zettabytes (10**21 bytes)
create units.data_size of n megabytes (10**6 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n mebibytes (1024**2 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
 => 
String
[Inherited from  Type]
name of this type, including type parameters, e.g. 'option (list i32)'.
create units.data_size of n petabytes (10**15 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n pebibytes (1024**5 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
 => 
String
[Inherited from  Type]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.

NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913

redefines:

create units.data_size of n quettabytes (10**30 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n quebibytes (1024**10 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n ronnabytes (10**27 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n robibytes (1024**9 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n terabytes (10**12 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n tebibytes (1024**4 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
 => 
Type
[Inherited from  Any]
Get a type as a value.

This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.

`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
create units.data_size of n yottabytes (10**24 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n yobibytes (1024**8 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
create units.data_size of n zettabytes (10**21 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls
the zero units.data_size, representing a zero bytes
create units.data_size of n zebibytes (1024**7 bytes)

NYI: Turn this into a 'postfix' call, see https://fuzion-lang.dev/design/postfix_calls

Applicable universe features

These are features in universe, that have an argument with a type constraint that matches this features type and can therefore be used with it.
(T 
type
:
property.equatable, a T, b T)
 => 
bool
equals -- feature that compares two values using the equality relation
defined in their type
(T 
type
:
property.hashable, a T)
 => 
u64
hash of a value
(T 
type
:
property.equatable, a T, b T)
 => 
bool
infix = -- infix operation as shorthand for 'equals'
(T 
type
:
property.orderable, a T, b T)
 => 
bool
does this come strictly before other?
infix <= -- infix operation as shorthand for 'lteq'
(T 
type
:
property.orderable, a T, b T)
 => 
order
three-way comparison between this and other.

result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
(T 
type
:
property.equatable, a T, b T)
 => 
bool
infix = -- infix operation as shorthand for 'equals'
(T 
type
:
property.orderable, a T, b T)
 => 
bool
does this come strictly after other?
(T 
type
:
property.orderable, a T, b T)
 => 
bool
does this come after other?
is `a` contained in `Set` `s`?

This should usually be called using type inference as in

is `a` not contained in `Set` `s`?

This should usually be called using type inference as in

(T 
type
:
property.equatable, a T, b T)
 => 
bool
infix ≟ -- infix operation as shorthand for 'equals'
infix ≤ -- infix operation as shorthand for 'lteq'
(T 
type
:
property.orderable, a T, b T)
 => 
bool
does this come after other?
(T 
type
:
property.orderable, a T, b T)
 => 
order
three-way comparison between this and other.

result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
(T 
type
:
property.orderable, a T, b T)
 => 
bool
does this come strictly before other?
(T 
type
:
property.orderable, a T, b T)
 => 
bool
does this come strictly after other?
(T 
type
:
property.partially_orderable, a T, b T)
 => 
bool
lteq -- feature that compares two values using the lteq relation
defined in their type
(T 
type
:
property.orderable, a T, b T)
 => 
T
maximum of two values
memoize `f`.
wraps f so that f will only be called once for every unique input.

The term "memoization" was coined by Donald Michie in 1968 and
is derived from the Latin word "memorandum" ("to be remembered"),
usually truncated as "memo" in American English, and thus carries
the meaning of "turning a function into something to be remembered".
https://en.wikipedia.org/wiki/Memoization

example:

(T 
type
:
property.orderable, a T, b T)
 => 
T
minimum of two values
0.095dev (2026-02-20 12:42:29 GIT hash dbcc3e4b3d2a59f66230b482cff8f0b018178d77 built by fridi@fzen)