Atmoos.Quantities 1.2.0

dotnet add package Atmoos.Quantities --version 1.2.0
NuGet\Install-Package Atmoos.Quantities -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Atmoos.Quantities" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Atmoos.Quantities --version 1.2.0
#r "nuget: Atmoos.Quantities, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Atmoos.Quantities as a Cake Addin
#addin nuget:?package=Atmoos.Quantities&version=1.2.0

// Install Atmoos.Quantities as a Cake Tool
#tool nuget:?package=Atmoos.Quantities&version=1.2.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

They are all compatible with each other.

Supported Quantities

The currently supported quantities are:

Quantities
├── Area
├── Data
├── DataRate
├── ElectricCurrent
├── ElectricPotential
├── ElectricalResistance
├── Energy
├── Force
├── 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.

├── Si
│   ├── Ampere
│   ├── Candela
│   ├── Derived
│   │   └── Celsius
│   ├── Kelvin
│   ├── Kilogram
│   ├── Metre
│   ├── Metric
│   │   ├── Hour
│   │   ├── Litre
│   │   └── Minute
│   ├── Mole
│   └── Second
└── Imperial
    ├── Length
    │   ├── Foot
    │   ├── Inch
    │   └── Mile
    ├── Mass
    │   └── Pound
    ├── Temperature
    │   └── Fahrenheit
    └── Volume
        └── Pint
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.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.

Version Downloads Last updated
1.2.0 115 4/9/2024
1.1.1 146 3/22/2024
1.1.0 165 2/4/2024
1.0.0 328 11/26/2023