Enum PrefixStyle
Specifies ways that a string must be represented in terms of prefix style.
Examples
Control how data prefix tables format output using binary (powers of 1024) or decimal (powers of 10) scales. This example demonstrates the ToString(PrefixStyle) method on DataPrefixTable to display the same byte quantity in two different prefix styles, allowing you to see how the same value appears with binary vs. decimal formatting:
using System;
using Codebelt.Unitify;
namespace Unitify.Samples;
public class PrefixStyleExample
{
public static void Main()
{
// Create a data unit table
var byteUnit = UnitFactory.CreateByte(1048576); // 1,048,576 bytes
var dataTable = new DataPrefixTable(byteUnit);
// Display with binary style formatting (1024-based prefixes)
Console.WriteLine("Binary prefix style (powers of 1024):");
Console.WriteLine(dataTable.ToString(PrefixStyle.Binary));
Console.WriteLine("\nDecimal prefix style (powers of 10):");
Console.WriteLine(dataTable.ToString(PrefixStyle.Decimal));
}
}
public enum PrefixStyle
Fields
Binary = 0Defines the IEEE 1541 standard for binary prefix that refers strictly to powers of 2 (eg. one kibibit represents 1024 bits and not 1000 bits).
Decimal = 1Defines the International System of Units (SI) standard for metric prefixes that refers strictly to powers of 10 (eg. one kilobit represents 1000 bits and not 1024 bits).