Class DecimalPrefix
Defines a decimal (metric) unit prefix for multiples and submultiples of measurement that refers strictly to powers of 10. This class cannot be inherited.
Examples
Use decimal (metric) prefixes (kilo, mega, milli, micro, etc.) for SI measurements. This example retrieves prefix constants, extracts their symbols and multiplier values, converts raw measurements to prefixed scales using ToPrefixValue(), and shows how to construct PrefixUnit objects that apply different scales to physical quantities:
using System;
using Codebelt.Unitify;
namespace Unitify.Samples;
public class DecimalPrefixExample
{
public static void Main()
{
// Get the kilo prefix (10^3)
var kilo = DecimalPrefix.Kilo;
Console.WriteLine($"Kilo symbol: {kilo.Symbol}");
Console.WriteLine($"Kilo multiplier: {kilo.Multiplier}");
// Convert a value to kilo scale
var meters = 5000.0;
var kilometers = kilo.ToPrefixValue(meters);
Console.WriteLine($"{meters} m = {kilometers} km");
// Create a watt unit with kilo prefix
var kilowatt = new PrefixUnit(Unit.Watt, 5, DecimalPrefix.Kilo);
Console.WriteLine($"Power: {kilowatt}");
// Work with micro prefix for small values
var micro = DecimalPrefix.Micro;
var amperes = 0.000005;
var microamperes = micro.ToPrefixValue(amperes);
Console.WriteLine($"{amperes} A = {microamperes} µA");
}
}
public sealed class DecimalPrefix : Prefix, IPrefix
- Inheritance
-
DecimalPrefix
- Implements
- Inherited Members
- Extension Methods
Constructors
DecimalPrefix(string, string, double)
Initializes a new instance of the DecimalPrefix class.
public DecimalPrefix(string name, string symbol, double exponent)
Parameters
namestringThe name of the decimal prefix.
symbolstringThe symbol of the decimal prefix.
exponentdoubleThe number that specifies a power.
Properties
Atto
Gets the decimal-submultiple prefix atto (symbol 'a'), 10^-18 = 0.000000000000000001.
public static DecimalPrefix Atto { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix atto (symbol 'a').
Centi
Gets the decimal-submultiple prefix centi (symbol 'c'), 10^-2 = 0.01.
public static DecimalPrefix Centi { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix centi (symbol 'c').
Deca
Gets the decimal-multiple prefix deca (symbol 'da'), 10^1 = 10.
public static DecimalPrefix Deca { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix deca (symbol 'da').
Deci
Gets the decimal-submultiple prefix deci (symbol 'd'), 10^-1 = 0.1.
public static DecimalPrefix Deci { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix deci (symbol 'd').
Exa
Gets the decimal-multiple prefix exa (symbol 'E'), 10^18 = 1000000000000000000.
public static DecimalPrefix Exa { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix exa (symbol 'E').
Femto
Gets the decimal-submultiple prefix femto (symbol 'f'), 10^-15 = 0.000000000000001.
public static DecimalPrefix Femto { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix femto (symbol 'f').
Giga
Gets the decimal-multiple prefix giga (symbol 'G'), 10^9 = 1000000000.
public static DecimalPrefix Giga { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix giga (symbol 'G').
Hecto
Gets the decimal-multiple prefix hecto (symbol 'h'), 10^2 = 100.
public static DecimalPrefix Hecto { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix hecto (symbol 'h').
Kilo
Gets the decimal-multiple prefix kilo (symbol 'k'), 10^3 = 1000.
public static DecimalPrefix Kilo { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix kilo (symbol 'k').
Mega
Gets the decimal-multiple prefix mega (symbol 'M'), 10^6 = 1000000.
public static DecimalPrefix Mega { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix mega (symbol 'M').
MetricPrefixes
Gets the complete sequence of multiples and submultiples metric prefixes as specified by International System of Units (SI).
public static IEnumerable<DecimalPrefix> MetricPrefixes { get; }
Property Value
- IEnumerable<DecimalPrefix>
The complete sequence of multiples and submultiples metric prefixes as specified by International System of Units (SI).
Micro
Gets the decimal-submultiple prefix micro (symbol 'μ'), 10^-6 = 0.000001.
public static DecimalPrefix Micro { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix micro (symbol 'μ').
Milli
Gets the decimal-submultiple prefix milli (symbol 'μ'), 10^-3 = 0.001.
public static DecimalPrefix Milli { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix milli (symbol 'μ').
Nano
Gets the decimal-submultiple prefix nano (symbol 'n'), 10^-9 = 0.000000001.
public static DecimalPrefix Nano { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix nano (symbol 'n').
Peta
Gets the decimal-multiple prefix peta (symbol 'P'), 10^15 = 1000000000000000.
public static DecimalPrefix Peta { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix peta (symbol 'P').
Pico
Gets the decimal-submultiple prefix pico (symbol 'f'), 10^-12 = 0.000000000001.
public static DecimalPrefix Pico { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix pico (symbol 'f').
Quecto
Gets the decimal-submultiple prefix quecto (symbol 'q'), 10^-30 = 0.000000000000000000000000000001.
public static DecimalPrefix Quecto { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix quecto (symbol 'q').
Quetta
Gets the decimal-multiple prefix quetta (symbol 'Q'), 10^30 = 1000000000000000000000000000000.
public static DecimalPrefix Quetta { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix quetta (symbol 'Q').
Ronna
Gets the decimal-multiple prefix ronna (symbol 'R'), 10^27 = 1000000000000000000000000000.
public static DecimalPrefix Ronna { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix ronna (symbol 'R').
Ronto
Gets the decimal-submultiple prefix ronto (symbol 'r'), 10^-27 = 0.000000000000000000000000001.
public static DecimalPrefix Ronto { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix ronto (symbol 'r').
Tera
Gets the decimal-multiple prefix tera (symbol 'T'), 10^12 = 1000000000000.
public static DecimalPrefix Tera { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix tera (symbol 'T').
Yocto
Gets the decimal-submultiple prefix yocto (symbol 'y'), 10^-24 = 0.000000000000000000000001.
public static DecimalPrefix Yocto { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix yocto (symbol 'y').
Yotta
Gets the decimal-multiple prefix yotta (symbol 'Y'), 10^24 = 1000000000000000000000000.
public static DecimalPrefix Yotta { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix yotta (symbol 'Y').
Zepto
Gets the decimal-submultiple prefix zepto (symbol 'z'), 10^-21 = 0.000000000000000000001.
public static DecimalPrefix Zepto { get; }
Property Value
- DecimalPrefix
The decimal-submultiple prefix zepto (symbol 'z').
Zetta
Gets the decimal-multiple prefix zetta (symbol 'Z'), 10^21 = 1000000000000000000000.
public static DecimalPrefix Zetta { get; }
Property Value
- DecimalPrefix
The decimal-multiple prefix zetta (symbol 'Z').