Version: dev

unit

Stable type · Units

Tier: stable · Kind: type · Topic: Units

JuliaTypeScriptPythonRustGo
not exportednot exportednot exportedUnitUnit

Julia

Julia does not export this type.

TypeScript

TypeScript does not export this type.

Python

Python does not export this type.

Rust

pub struct Unit {
    /* private fields */
}

impl Unit { pub fn scale(&self) -> f64 }

impl Unit { pub fn exact_scale(&self) -> &ExactScale }

impl Unit { pub fn same_unit(&self, other: &Unit) -> bool }

impl Unit { pub fn same_dimensions(&self, other: &Unit) -> bool }

impl Unit { pub fn dimensionless() -> Self }

impl Unit { pub fn base(dimension: Dimension, power: i32, scale: f64) -> Self }

impl Unit { pub fn base_rational(dimension: Dimension, power: Rational, scale: f64) -> Self }

impl Unit { pub fn is_compatible(&self, other: &Unit) -> bool }

impl Unit { pub fn is_dimensionless(&self) -> bool }

impl Unit { pub fn is_pure_number(&self) -> bool }

impl Unit { pub fn is_plane_angle(&self) -> bool }

impl Unit { pub fn multiply(&self, other: &Unit) -> Unit }

impl Unit { pub fn divide(&self, other: &Unit) -> Unit }

impl Unit { pub fn power(&self, exponent: i32) -> Unit }

impl Unit { pub fn power_rational(&self, exponent: Rational) -> Unit }

impl Unit { pub fn propagate(expr: &Expr, env: &HashMap<String, Unit>) -> Result<Unit, UnitError> }

Represents a physical unit with dimensions

Source · Rust docs

Go

type Unit struct {
	Dim    Dimension
	Scale  float64
	Symbol string
	// Exact is the scale every agreement is decided on (esm-spec §4.8.1). Its
	// zero value is exactly 1, so a unit literal with Scale 1 needs no Exact.
	Exact ExactScale
}

func (u Unit) Divide(other Unit) Unit

func (u Unit) Multiply(other Unit) Unit

func (u Unit) Power(n int) Unit

func (u Unit) PowerRat(e Rat) Unit

Unit is a named physical unit with a dimension vector and a scale factor relative to the canonical SI combination represented by Dim.

Methods

func (u Unit) Divide(other Unit) Unit

Divide returns the quotient of two units.

func (u Unit) Multiply(other Unit) Unit

Multiply returns the product of two units (dimensions add, scales multiply).

func (u Unit) Power(n int) Unit

Power raises a unit to an integer power.

func (u Unit) PowerRat(e Rat) Unit

PowerRat raises a unit to a RATIONAL power (s^(-1/2), sqrt(m^3)).

Source · Go docs