Atmoos.Quantities
1.3.0
dotnet add package Atmoos.Quantities --version 1.3.0
NuGet\Install-Package Atmoos.Quantities -Version 1.3.0
<PackageReference Include="Atmoos.Quantities" Version="1.3.0" />
paket add Atmoos.Quantities --version 1.3.0
#r "nuget: Atmoos.Quantities, 1.3.0"
// Install Atmoos.Quantities as a Cake Addin #addin nuget:?package=Atmoos.Quantities&version=1.3.0 // Install Atmoos.Quantities as a Cake Tool #tool nuget:?package=Atmoos.Quantities&version=1.3.0
Atmoos.Quantities
This library enables type-safe handling of quantities. It is a general purpose library that allows third parties to define their own units if needed. Many units are predefined in this library or are available on nuget here.
It is based on the international system of units (SI), but also supports many other units, such as imperial units.
Design principles:
- Type-safe by default.
- General purpose, i.e. extendable.
- Broad set of units available in Atmoos.Quantities.Units.
- Custom units are supported, too.
- All metric and binary prefixes are supported.
- Serialization is supported via Atmoos.Quantities.Serialization
- Optimized for
- accuracy: numerically more stable than just using doubles.
- low memory footprint: all quantities are structs and don't allocate on the heap.
- speed: likely faster than naive implementations.
Usage Patterns
Add this global using somewhere in your project.
global using static Quantities.Systems;
Then, quantities can be used like this:
Time hours = Time.Of(4, Metric<Hour>());
Length feet = Length.Of(2, Imperial<Foot>());
Volume volume = Volume.Of(3, Cubic(Si<Metre>()));
Length kilometres = Length.Of(16, Si<Kilo, Metre>());
Velocity kilometresPerHour = Velocity.Of(4, Si<Kilo, Metre>().Per(Metric<Hour>()));
Velocity arithmeticVelocity = kilometres / hours; // 4 km/h
Area area = volume / feet; // 4.921... m²
Supported Si Prefixes
- All metric prefixes
Quecto
through toQuetta
. - All binary prefixes
Kibi
through toYobi
.
They are all compatible with each other.
Supported Quantities
The currently supported quantities are:
Atmoos.Quantities
├── Area
├── Data
├── DataRate
├── ElectricalResistance
├── ElectricCurrent
├── ElectricPotential
├── Energy
├── Force
├── Frequency
├── Length
├── Mass
├── Power
├── Temperature
├── Time
├── Velocity
└── Volume
They support a broad range of compatible units as indicated by the examples above.
Supported Units of Measurement
The following units are included in this library. Please see Atmoos.Quantities.Units for many more units.
Atmoos.Quantities.Units
├── Si
│ ├── Ampere
│ ├── Candela
│ ├── Kelvin
│ ├── Kilogram
│ ├── Metre
│ ├── Mole
│ ├── Second
│ └── Metric
│ ├── Temperature
│ │ └── Celsius
│ ├── Time
│ │ ├── Hour
│ │ └── Minute
│ └── Volume
│ └── Litre
└── Imperial
├── Length
│ ├── Foot
│ ├── Inch
│ └── Mile
├── Mass
│ └── Pound
├── Temperature
│ └── Fahrenheit
└── Volume
└── Pint
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Atmoos.Quantities:
Package | Downloads |
---|---|
Atmoos.Quantities.Units
Provides many more units for use with Atmoos.Atmoos.Quantities. |
|
Atmoos.Quantities.Serialization.Text.Json
Serialization of Atmoos.Quantities types with System.Text.Json. |
|
Atmoos.Quantities.Serialization.Newtonsoft
Serialization of Atmoos.Quantities types with Newtonsoft.Json. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Please see: https://github.com/atmoos/Quantities/releases