Table of Contents

DecimalPrefix Class

Definition

Namespace
Codebelt.Unitify
Assemblies
Codebelt.Unitify.dll
Source
src/Codebelt.Unitify/DecimalPrefix.cs

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

Name Description
DecimalPrefix(string, string, double)

Initializes a new instance of the DecimalPrefix class.

Properties

Name Description
Atto

Gets the decimal-submultiple prefix atto (symbol 'a'), 10^-18 = 0.000000000000000001.

Centi

Gets the decimal-submultiple prefix centi (symbol 'c'), 10^-2 = 0.01.

Deca

Gets the decimal-multiple prefix deca (symbol 'da'), 10^1 = 10.

Deci

Gets the decimal-submultiple prefix deci (symbol 'd'), 10^-1 = 0.1.

Exa

Gets the decimal-multiple prefix exa (symbol 'E'), 10^18 = 1000000000000000000.

Femto

Gets the decimal-submultiple prefix femto (symbol 'f'), 10^-15 = 0.000000000000001.

Giga

Gets the decimal-multiple prefix giga (symbol 'G'), 10^9 = 1000000000.

Hecto

Gets the decimal-multiple prefix hecto (symbol 'h'), 10^2 = 100.

Kilo

Gets the decimal-multiple prefix kilo (symbol 'k'), 10^3 = 1000.

Mega

Gets the decimal-multiple prefix mega (symbol 'M'), 10^6 = 1000000.

MetricPrefixes

Gets 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.

Milli

Gets the decimal-submultiple prefix milli (symbol 'm'), 10^-3 = 0.001.

Nano

Gets the decimal-submultiple prefix nano (symbol 'n'), 10^-9 = 0.000000001.

Peta

Gets the decimal-multiple prefix peta (symbol 'P'), 10^15 = 1000000000000000.

Pico

Gets the decimal-submultiple prefix pico (symbol 'p'), 10^-12 = 0.000000000001.

Quecto

Gets the decimal-submultiple prefix quecto (symbol 'q'), 10^-30 = 0.000000000000000000000000000001.

Quetta

Gets the decimal-multiple prefix quetta (symbol 'Q'), 10^30 = 1000000000000000000000000000000.

Ronna

Gets the decimal-multiple prefix ronna (symbol 'R'), 10^27 = 1000000000000000000000000000.

Ronto

Gets the decimal-submultiple prefix ronto (symbol 'r'), 10^-27 = 0.000000000000000000000000001.

Tera

Gets the decimal-multiple prefix tera (symbol 'T'), 10^12 = 1000000000000.

Yocto

Gets the decimal-submultiple prefix yocto (symbol 'y'), 10^-24 = 0.000000000000000000000001.

Yotta

Gets the decimal-multiple prefix yotta (symbol 'Y'), 10^24 = 1000000000000000000000000.

Zepto

Gets the decimal-submultiple prefix zepto (symbol 'z'), 10^-21 = 0.000000000000000000001.

Zetta

Gets the decimal-multiple prefix zetta (symbol 'Z'), 10^21 = 1000000000000000000000.

See Also