MetricPrefix

Metric prefix struct.

Usage example:

import ocean.text.util.MetricPrefix;

// Number to display in metric prefixed mode.
const number = 2876873683;

// Struct instance
MetricPrefix metric;

// Calculate the binary metric prefix of the number.
metric.bin(number);

// Output metric prefixed string (2.679297405Gb, in this case).
Stdout.formatln("{}{}b", metric.scaled, metric.prefix);

Members

Functions

bin
typeof(&this) bin(T n)

Converts n into a metric-like prefixed representation, using powers of 1024.

dec
typeof(&this) dec(T n, int e)

Converts n into a metric prefixed representation.

Manifest constants

BinaryPrefixes
enum BinaryPrefixes;
Undocumented in source.
DecimalPrefixes
enum DecimalPrefixes;
Undocumented in source.

Variables

prefix
dchar prefix;

Metric decimal power unit prefix; set by bin()/dec()

scaled
float scaled;

Scaled mantissa; set by bin()/dec()

Meta