Skip to content

Commit

Permalink
Merge pull request #13 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
RC2.1
  • Loading branch information
adrianstevens authored Jan 2, 2023
2 parents 685da81 + c2c3101 commit bb4bb34
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Source/Meadow.Units/Temperature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ public struct Temperature :
IComparable, IFormattable, IConvertible,
IEquatable<double>, IComparable<double>
{
public static Temperature AbsoluteZero = new Temperature(0, UnitType.Kelvin);
/// <summary>
/// Absolute Zero temperature.
/// </summary>
public static Temperature AbsoluteZero = new (0, UnitType.Kelvin);

/// <summary>
/// Creates a new `Temperature` object.
/// </summary>
/// <param name="value">The temperature value.</param>
/// <param name="type">_Celsius_ (``), by default.</param>
/// <param name="type">_Celsius_ (`°C`), by default.</param>
public Temperature(double value, UnitType type = UnitType.Celsius)
{
Value = 0;
Expand All @@ -43,11 +46,14 @@ public Temperature(double value, UnitType type = UnitType.Celsius)
break;
}

if (this < AbsoluteZero) throw new ArgumentOutOfRangeException();
if (this.Kelvin < 0)
{
throw new ArgumentOutOfRangeException("Temperature cannot be less than 0 Kelvin");
}
}

/// <summary>
/// Creates a new `Temperature` object from an existing Temperature object
/// Creates a new `Temperature` object from an existing Temperature object.
/// </summary>
/// <param name="temperature"></param>
public Temperature(Temperature temperature)
Expand Down

0 comments on commit bb4bb34

Please sign in to comment.