splitBinaryPrefix

Splits the given number by binary prefixes (K, M, T, etc), passing the prefix character, the prefix order and the count per prefix to the output delegate.

void
splitBinaryPrefix
(
ulong n
,
scope void delegate
(
char prefix
,
uint order
,
ulong order_val
)
output_dg
)

Parameters

n ulong

number to split

output_dg void delegate
(
char prefix
,
uint order
,
ulong order_val
)

delegate which receives prefix values

See also: BitGrouping in ocean.text.util.DigitGrouping, for a method which automatically formats a split binary prefix string.

Note that if n == 0, the output delegate will not be called.

Usage example:

import ocean.text.util.MetricPrefix;

// Number to split by binary prefix.
const number = 2876873683;

// Delegate which receives the split info.
void split ( char prefix, uint order, ulong order_val )
{
    Stdout.formatln("Order {}: {}{}", order, order_val, prefix);
}

// Perform the split.
splitBinaryPrefix(number, &split);

Meta