Struct PressureUnit
Encapsulates a pressure, stored internally as a double in pascals (Pa), and provides
properties that allow lossless conversion to and from a comprehensive range of pressure units --
spanning SI sub-pascal prefixes (yoctopascal up to terapascal), the bar family (millibar, bar,
megabar), water- and mercury-column units, and imperial/gravimetric units such as psi, psf, ksi,
and kgf/cm².
Implements
Inherited Members
Namespace: Scylla.Core.Util.Units
Assembly: ScyllaCore.dll
Syntax
public struct PressureUnit : IEquatable<PressureUnit>
Remarks
All property setters validate the incoming value via EnsureFinite(float, string) and will throw ArgumentOutOfRangeException if NaN or infinity is assigned. This makes PressureUnit safe for use in deterministic simulation code where silent propagation of invalid values would be harmful.
Equality comparisons (operator ==(PressureUnit, PressureUnit), Equals(PressureUnit)) use
Approximately(float, float, float) to account for floating-point
rounding. Relational operators (<, >, <=, >=)
use exact comparison.
Use ToString() for a human-friendly auto-scaled label using SI and bar units, or read the appropriate property directly for non-SI units.
// Construct from different units.
var onePSI = new PressureUnit { PoundPerSquareInch = 1.0 };
var oneAtm = new PressureUnit { StandardAtmosphere = 1.0 };
// Convert freely between units.
double kPa = onePSI.Kilopascal; // ~6.895
double mmHg = oneAtm.MillimeterOfMercury; // 760.0
// Arithmetic.
PressureUnit combined = onePSI + oneAtm;
PressureUnit halved = combined / 2d;
Constructors
PressureUnit(double)
Initializes a new PressureUnit with the given pressure in pascals.
Declaration
public PressureUnit(double pascals = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| double | pascals | The pressure expressed in pascals (Pa). Any finite |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
Properties
Attopascal
The pressure in attopascals (aPa), where 1 aPa = 10^-18 Pa.
Declaration
public double Attopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Bar
The pressure in bars (bar), where 1 bar = 100,000 Pa.
Declaration
public double Bar { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Barye
The pressure in barye (Ba), where 1 Ba = 0.1 Pa.
Declaration
public double Barye { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
CentimeterOfWater
The pressure in centimeters of water (cmH₂O).
Declaration
public double CentimeterOfWater { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Decapascal
The pressure in decapascals (daPa), where 1 daPa = 10 Pa.
Declaration
public double Decapascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Femtopascal
The pressure in femtopascals (fPa), where 1 fPa = 10^-15 Pa.
Declaration
public double Femtopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Gigapascal
The pressure in gigapascals (GPa), where 1 GPa = 10^9 Pa.
Declaration
public double Gigapascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Hectopascal
The pressure in hectopascals (hPa), where 1 hPa = 100 Pa.
Declaration
public double Hectopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
InchOfMercury
The pressure in inches of mercury (inHg).
Declaration
public double InchOfMercury { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
InchOfWater
The pressure in inches of water (inH₂O).
Declaration
public double InchOfWater { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
KilogramForcePerSquareCentimeter
The pressure in kilogram-force per square centimeter (kgf/cm²).
Declaration
public double KilogramForcePerSquareCentimeter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Kilopascal
The pressure in kilopascals (kPa), where 1 kPa = 1000 Pa.
Declaration
public double Kilopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
KipsPerSquareInch
The pressure in kips per square inch (ksi).
Declaration
public double KipsPerSquareInch { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Megabar
The pressure in megabars (Mbar), where 1 Mbar = 10^6 bar.
Declaration
public double Megabar { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Megapascal
The pressure in megapascals (MPa), where 1 MPa = 10^6 Pa.
Declaration
public double Megapascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
MeterOfWater
The pressure in meters of water (mH₂O).
Declaration
public double MeterOfWater { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Micropascal
The pressure in micropascals (µPa), where 1 µPa = 10^-6 Pa.
Declaration
public double Micropascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Millibar
The pressure in millibars (mbar), where 1 mbar = 100 Pa.
Declaration
public double Millibar { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
MillimeterOfMercury
The pressure in millimeters of mercury (mmHg).
Declaration
public double MillimeterOfMercury { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
MillimeterOfWater
The pressure in millimeters of water (mmH₂O).
Declaration
public double MillimeterOfWater { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Millipascal
The pressure in millipascals (mPa), where 1 mPa = 10^-3 Pa.
Declaration
public double Millipascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Nanopascal
The pressure in nanopascals (nPa), where 1 nPa = 10^-9 Pa.
Declaration
public double Nanopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Pascal
Gets or sets the pressure expressed in pascals (Pa). This is the canonical internal representation; reading or writing this property involves no unit conversion.
Declaration
public double Pascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
All other unit properties delegate their setters through Pascal.
Setting this property validates the incoming value with
EnsureFinite(float, string) and throws
ArgumentOutOfRangeException if NaN or infinity is supplied.
Picopascal
The pressure in picopascals (pPa), where 1 pPa = 10^-12 Pa.
Declaration
public double Picopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
PoundPerSquareFoot
The pressure in pounds per square foot (psf).
Declaration
public double PoundPerSquareFoot { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
PoundPerSquareInch
The pressure in pounds per square inch (psi).
Declaration
public double PoundPerSquareInch { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
StandardAtmosphere
The pressure in standard atmospheres (atm), where 1 atm = 101,325 Pa.
Declaration
public double StandardAtmosphere { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
TechnicalAtmosphere
The pressure in technical atmospheres (at), where 1 at = 98,066.5 Pa.
Declaration
public double TechnicalAtmosphere { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Terapascal
The pressure in terapascals (TPa), where 1 TPa = 10^12 Pa.
Declaration
public double Terapascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Torr
The pressure in torr (Torr), where 1 Torr = 1/760 atm.
Declaration
public double Torr { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Yoctopascal
The pressure in yoctopascals (yPa), where 1 yPa = 10^-24 Pa.
Declaration
public double Yoctopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Zeptopascal
The pressure in zeptopascals (zPa), where 1 zPa = 10^-21 Pa.
Declaration
public double Zeptopascal { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Methods
Equals(PressureUnit)
Determines whether the current PressureUnit instance is approximately equal to another specified PressureUnit, using Approximately(float, float, float) to tolerate floating-point rounding differences.
Declaration
public bool Equals(PressureUnit other)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | other | The PressureUnit to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Equals(object)
Determines whether the specified object is equal to the current PressureUnit instance.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
GetHashCode()
Computes the hash code for the current PressureUnit instance, derived from the internal pascal value.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer hash code representing the current PressureUnit. |
Overrides
ToString()
Returns a human-readable string that represents the pressure using the most appropriate unit for the current magnitude, automatically scaling across SI pascal prefixes and the bar family (mbar, bar, Mbar).
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string of the form |
Overrides
Remarks
The numeric portion is formatted with adaptive decimal precision: values >= 100 display zero decimals, values >= 10 display one decimal, and smaller values display two decimals. Trailing zeros and trailing decimal separators are trimmed.
Auto-selection does not include non-SI units such as psi, atm, or mmHg. For those units, read the corresponding property directly (e.g., PoundPerSquareInch, StandardAtmosphere, MillimeterOfMercury).
Operators
operator +(PressureUnit, PressureUnit)
Adds two PressureUnit values together.
Declaration
public static PressureUnit operator +(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit operand. |
| PressureUnit | right | The second PressureUnit operand. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing the sum of |
operator /(PressureUnit, PressureUnit)
Divides one PressureUnit value by another, returning the dimensionless
ratio of their internal pascal values as a double.
Declaration
public static double operator /(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The PressureUnit dividend. |
| PressureUnit | right | The PressureUnit divisor. Must not be zero. |
Returns
| Type | Description |
|---|---|
| double | A |
Exceptions
| Type | Condition |
|---|---|
| DivideByZeroException | Thrown when |
operator /(PressureUnit, double)
Divides a PressureUnit value by a double-precision floating-point scalar.
Declaration
public static PressureUnit operator /(PressureUnit left, double right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The PressureUnit dividend. |
| double | right | The scalar divisor. Must be a finite, non-zero value. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
| DivideByZeroException | Thrown when |
operator /(PressureUnit, int)
Divides a PressureUnit value by an integer scalar.
Declaration
public static PressureUnit operator /(PressureUnit left, int right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The PressureUnit dividend. |
| int | right | The integer divisor. Must not be zero. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing |
Exceptions
| Type | Condition |
|---|---|
| DivideByZeroException | Thrown when |
operator ==(PressureUnit, PressureUnit)
Determines whether two PressureUnit values are approximately equal, using Approximately(float, float, float) to tolerate floating-point rounding differences.
Declaration
public static bool operator ==(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit to compare. |
| PressureUnit | right | The second PressureUnit to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator >(PressureUnit, PressureUnit)
Determines whether one PressureUnit value is strictly greater than another, using exact comparison of the underlying pascal values.
Declaration
public static bool operator >(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit to compare. |
| PressureUnit | right | The second PressureUnit to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator >=(PressureUnit, PressureUnit)
Determines whether one PressureUnit value is greater than or equal to another, using exact comparison of the underlying pascal values.
Declaration
public static bool operator >=(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit to compare. |
| PressureUnit | right | The second PressureUnit to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(PressureUnit, PressureUnit)
Determines whether two PressureUnit values are not approximately equal, using Approximately(float, float, float) to tolerate floating-point rounding differences.
Declaration
public static bool operator !=(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit to compare. |
| PressureUnit | right | The second PressureUnit to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator <(PressureUnit, PressureUnit)
Determines whether one PressureUnit value is strictly less than another, using exact comparison of the underlying pascal values.
Declaration
public static bool operator <(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit to compare. |
| PressureUnit | right | The second PressureUnit to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator <=(PressureUnit, PressureUnit)
Determines whether one PressureUnit value is less than or equal to another, using exact comparison of the underlying pascal values.
Declaration
public static bool operator <=(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The first PressureUnit to compare. |
| PressureUnit | right | The second PressureUnit to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator *(PressureUnit, double)
Multiplies a PressureUnit value by a double-precision floating-point scalar.
Declaration
public static PressureUnit operator *(PressureUnit left, double right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The PressureUnit to scale. |
| double | right | The scalar multiplier. Must be a finite value (not NaN or infinity). |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
operator *(PressureUnit, int)
Multiplies a PressureUnit value by an integer scalar.
Declaration
public static PressureUnit operator *(PressureUnit left, int right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The PressureUnit to scale. |
| int | right | The integer scalar multiplier. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing |
operator *(double, PressureUnit)
Multiplies a double-precision floating-point scalar by a PressureUnit value.
Declaration
public static PressureUnit operator *(double left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| double | left | The scalar multiplier. Must be a finite value (not NaN or infinity). |
| PressureUnit | right | The PressureUnit to scale. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
operator *(int, PressureUnit)
Multiplies an integer scalar by a PressureUnit value.
Declaration
public static PressureUnit operator *(int left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| int | left | The integer scalar multiplier. |
| PressureUnit | right | The PressureUnit to scale. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing |
operator -(PressureUnit, PressureUnit)
Subtracts one PressureUnit value from another.
Declaration
public static PressureUnit operator -(PressureUnit left, PressureUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | left | The PressureUnit to subtract from. |
| PressureUnit | right | The PressureUnit to subtract. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit representing the difference of |
operator -(PressureUnit)
Returns the arithmetic negation of a PressureUnit value, inverting its sign.
Declaration
public static PressureUnit operator -(PressureUnit value)
Parameters
| Type | Name | Description |
|---|---|---|
| PressureUnit | value | The PressureUnit to negate. |
Returns
| Type | Description |
|---|---|
| PressureUnit | A new PressureUnit whose internal pascal value is the negation of |