diff --git a/Common/UnitDefinitions/BitRate.json b/Common/UnitDefinitions/BitRate.json
index 8f2ccd1e37..5418065bcc 100644
--- a/Common/UnitDefinitions/BitRate.json
+++ b/Common/UnitDefinitions/BitRate.json
@@ -1,7 +1,6 @@
{
"Name": "BitRate",
"BaseUnit": "BitPerSecond",
- "ValueType": "decimal",
"XmlDocSummary": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate",
"BaseDimensions": { "T": -1 },
@@ -22,8 +21,8 @@
{
"SingularName": "BytePerSecond",
"PluralName": "BytesPerSecond",
- "FromUnitToBaseFunc": "{x} * 8m",
- "FromBaseToUnitFunc": "{x} / 8m",
+ "FromUnitToBaseFunc": "{x} * 8",
+ "FromBaseToUnitFunc": "{x} / 8",
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
"Localization": [
{
diff --git a/Common/UnitDefinitions/Information.json b/Common/UnitDefinitions/Information.json
index 39cb9f0636..f327f00ca5 100644
--- a/Common/UnitDefinitions/Information.json
+++ b/Common/UnitDefinitions/Information.json
@@ -1,14 +1,13 @@
{
"Name": "Information",
"BaseUnit": "Bit",
- "ValueType": "decimal",
"XmlDocSummary": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.",
"Units": [
{
"SingularName": "Byte",
"PluralName": "Bytes",
- "FromUnitToBaseFunc": "{x} * 8m",
- "FromBaseToUnitFunc": "{x} / 8m",
+ "FromUnitToBaseFunc": "{x} * 8",
+ "FromBaseToUnitFunc": "{x} / 8",
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
"Localization": [
{
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs
index f126853b67..5ca2c65716 100644
--- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs
+++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs
@@ -69,12 +69,12 @@ public BitRate(double value, BitRateUnit unit)
///
/// Represents the largest possible value of BitRate.
///
- public static BitRate MaxValue { get; } = new BitRate(79228162514264337593543950335d, BaseUnit);
+ public static BitRate MaxValue { get; } = new BitRate(double.MaxValue, BaseUnit);
///
/// Represents the smallest possible value of BitRate.
///
- public static BitRate MinValue { get; } = new BitRate(-79228162514264337593543950335d, BaseUnit);
+ public static BitRate MinValue { get; } = new BitRate(double.MinValue, BaseUnit);
///
/// Gets an instance of this quantity with a value of 0 in the base unit Second.
@@ -413,31 +413,31 @@ private double GetValueInBaseUnit()
return Unit switch
{
BitRateUnit.BitPerSecond => _value,
- BitRateUnit.BytePerSecond => _value * 8d,
+ BitRateUnit.BytePerSecond => _value * 8,
BitRateUnit.ExabitPerSecond => (_value) * 1e18d,
- BitRateUnit.ExabytePerSecond => (_value * 8d) * 1e18d,
+ BitRateUnit.ExabytePerSecond => (_value * 8) * 1e18d,
BitRateUnit.ExbibitPerSecond => (_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
- BitRateUnit.ExbibytePerSecond => (_value * 8d) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
+ BitRateUnit.ExbibytePerSecond => (_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
BitRateUnit.GibibitPerSecond => (_value) * (1024d * 1024 * 1024),
- BitRateUnit.GibibytePerSecond => (_value * 8d) * (1024d * 1024 * 1024),
+ BitRateUnit.GibibytePerSecond => (_value * 8) * (1024d * 1024 * 1024),
BitRateUnit.GigabitPerSecond => (_value) * 1e9d,
- BitRateUnit.GigabytePerSecond => (_value * 8d) * 1e9d,
+ BitRateUnit.GigabytePerSecond => (_value * 8) * 1e9d,
BitRateUnit.KibibitPerSecond => (_value) * 1024d,
- BitRateUnit.KibibytePerSecond => (_value * 8d) * 1024d,
+ BitRateUnit.KibibytePerSecond => (_value * 8) * 1024d,
BitRateUnit.KilobitPerSecond => (_value) * 1e3d,
- BitRateUnit.KilobytePerSecond => (_value * 8d) * 1e3d,
+ BitRateUnit.KilobytePerSecond => (_value * 8) * 1e3d,
BitRateUnit.MebibitPerSecond => (_value) * (1024d * 1024),
- BitRateUnit.MebibytePerSecond => (_value * 8d) * (1024d * 1024),
+ BitRateUnit.MebibytePerSecond => (_value * 8) * (1024d * 1024),
BitRateUnit.MegabitPerSecond => (_value) * 1e6d,
- BitRateUnit.MegabytePerSecond => (_value * 8d) * 1e6d,
+ BitRateUnit.MegabytePerSecond => (_value * 8) * 1e6d,
BitRateUnit.PebibitPerSecond => (_value) * (1024d * 1024 * 1024 * 1024 * 1024),
- BitRateUnit.PebibytePerSecond => (_value * 8d) * (1024d * 1024 * 1024 * 1024 * 1024),
+ BitRateUnit.PebibytePerSecond => (_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024),
BitRateUnit.PetabitPerSecond => (_value) * 1e15d,
- BitRateUnit.PetabytePerSecond => (_value * 8d) * 1e15d,
+ BitRateUnit.PetabytePerSecond => (_value * 8) * 1e15d,
BitRateUnit.TebibitPerSecond => (_value) * (1024d * 1024 * 1024 * 1024),
- BitRateUnit.TebibytePerSecond => (_value * 8d) * (1024d * 1024 * 1024 * 1024),
+ BitRateUnit.TebibytePerSecond => (_value * 8) * (1024d * 1024 * 1024 * 1024),
BitRateUnit.TerabitPerSecond => (_value) * 1e12d,
- BitRateUnit.TerabytePerSecond => (_value * 8d) * 1e12d,
+ BitRateUnit.TerabytePerSecond => (_value * 8) * 1e12d,
_ => throw new NotImplementedException($"Can not convert {Unit} to base units.")
};
}
@@ -452,31 +452,31 @@ private double GetValueAs(BitRateUnit unit)
return unit switch
{
BitRateUnit.BitPerSecond => baseUnitValue,
- BitRateUnit.BytePerSecond => baseUnitValue / 8d,
+ BitRateUnit.BytePerSecond => baseUnitValue / 8,
BitRateUnit.ExabitPerSecond => (baseUnitValue) / 1e18d,
- BitRateUnit.ExabytePerSecond => (baseUnitValue / 8d) / 1e18d,
+ BitRateUnit.ExabytePerSecond => (baseUnitValue / 8) / 1e18d,
BitRateUnit.ExbibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
- BitRateUnit.ExbibytePerSecond => (baseUnitValue / 8d) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
+ BitRateUnit.ExbibytePerSecond => (baseUnitValue / 8) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
BitRateUnit.GibibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024),
- BitRateUnit.GibibytePerSecond => (baseUnitValue / 8d) / (1024d * 1024 * 1024),
+ BitRateUnit.GibibytePerSecond => (baseUnitValue / 8) / (1024d * 1024 * 1024),
BitRateUnit.GigabitPerSecond => (baseUnitValue) / 1e9d,
- BitRateUnit.GigabytePerSecond => (baseUnitValue / 8d) / 1e9d,
+ BitRateUnit.GigabytePerSecond => (baseUnitValue / 8) / 1e9d,
BitRateUnit.KibibitPerSecond => (baseUnitValue) / 1024d,
- BitRateUnit.KibibytePerSecond => (baseUnitValue / 8d) / 1024d,
+ BitRateUnit.KibibytePerSecond => (baseUnitValue / 8) / 1024d,
BitRateUnit.KilobitPerSecond => (baseUnitValue) / 1e3d,
- BitRateUnit.KilobytePerSecond => (baseUnitValue / 8d) / 1e3d,
+ BitRateUnit.KilobytePerSecond => (baseUnitValue / 8) / 1e3d,
BitRateUnit.MebibitPerSecond => (baseUnitValue) / (1024d * 1024),
- BitRateUnit.MebibytePerSecond => (baseUnitValue / 8d) / (1024d * 1024),
+ BitRateUnit.MebibytePerSecond => (baseUnitValue / 8) / (1024d * 1024),
BitRateUnit.MegabitPerSecond => (baseUnitValue) / 1e6d,
- BitRateUnit.MegabytePerSecond => (baseUnitValue / 8d) / 1e6d,
+ BitRateUnit.MegabytePerSecond => (baseUnitValue / 8) / 1e6d,
BitRateUnit.PebibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024),
- BitRateUnit.PebibytePerSecond => (baseUnitValue / 8d) / (1024d * 1024 * 1024 * 1024 * 1024),
+ BitRateUnit.PebibytePerSecond => (baseUnitValue / 8) / (1024d * 1024 * 1024 * 1024 * 1024),
BitRateUnit.PetabitPerSecond => (baseUnitValue) / 1e15d,
- BitRateUnit.PetabytePerSecond => (baseUnitValue / 8d) / 1e15d,
+ BitRateUnit.PetabytePerSecond => (baseUnitValue / 8) / 1e15d,
BitRateUnit.TebibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024 * 1024),
- BitRateUnit.TebibytePerSecond => (baseUnitValue / 8d) / (1024d * 1024 * 1024 * 1024),
+ BitRateUnit.TebibytePerSecond => (baseUnitValue / 8) / (1024d * 1024 * 1024 * 1024),
BitRateUnit.TerabitPerSecond => (baseUnitValue) / 1e12d,
- BitRateUnit.TerabytePerSecond => (baseUnitValue / 8d) / 1e12d,
+ BitRateUnit.TerabytePerSecond => (baseUnitValue / 8) / 1e12d,
_ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.")
};
}
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs
index e77bcdce10..e1bc7cc7fc 100644
--- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs
+++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs
@@ -66,12 +66,12 @@ public Information(double value, InformationUnit unit)
///
/// Represents the largest possible value of Information.
///
- public static Information MaxValue { get; } = new Information(79228162514264337593543950335d, BaseUnit);
+ public static Information MaxValue { get; } = new Information(double.MaxValue, BaseUnit);
///
/// Represents the smallest possible value of Information.
///
- public static Information MinValue { get; } = new Information(-79228162514264337593543950335d, BaseUnit);
+ public static Information MinValue { get; } = new Information(double.MinValue, BaseUnit);
///
/// Gets an instance of this quantity with a value of 0 in the base unit Second.
@@ -410,31 +410,31 @@ private double GetValueInBaseUnit()
return Unit switch
{
InformationUnit.Bit => _value,
- InformationUnit.Byte => _value * 8d,
+ InformationUnit.Byte => _value * 8,
InformationUnit.Exabit => (_value) * 1e18d,
- InformationUnit.Exabyte => (_value * 8d) * 1e18d,
+ InformationUnit.Exabyte => (_value * 8) * 1e18d,
InformationUnit.Exbibit => (_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
- InformationUnit.Exbibyte => (_value * 8d) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
+ InformationUnit.Exbibyte => (_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
InformationUnit.Gibibit => (_value) * (1024d * 1024 * 1024),
- InformationUnit.Gibibyte => (_value * 8d) * (1024d * 1024 * 1024),
+ InformationUnit.Gibibyte => (_value * 8) * (1024d * 1024 * 1024),
InformationUnit.Gigabit => (_value) * 1e9d,
- InformationUnit.Gigabyte => (_value * 8d) * 1e9d,
+ InformationUnit.Gigabyte => (_value * 8) * 1e9d,
InformationUnit.Kibibit => (_value) * 1024d,
- InformationUnit.Kibibyte => (_value * 8d) * 1024d,
+ InformationUnit.Kibibyte => (_value * 8) * 1024d,
InformationUnit.Kilobit => (_value) * 1e3d,
- InformationUnit.Kilobyte => (_value * 8d) * 1e3d,
+ InformationUnit.Kilobyte => (_value * 8) * 1e3d,
InformationUnit.Mebibit => (_value) * (1024d * 1024),
- InformationUnit.Mebibyte => (_value * 8d) * (1024d * 1024),
+ InformationUnit.Mebibyte => (_value * 8) * (1024d * 1024),
InformationUnit.Megabit => (_value) * 1e6d,
- InformationUnit.Megabyte => (_value * 8d) * 1e6d,
+ InformationUnit.Megabyte => (_value * 8) * 1e6d,
InformationUnit.Pebibit => (_value) * (1024d * 1024 * 1024 * 1024 * 1024),
- InformationUnit.Pebibyte => (_value * 8d) * (1024d * 1024 * 1024 * 1024 * 1024),
+ InformationUnit.Pebibyte => (_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024),
InformationUnit.Petabit => (_value) * 1e15d,
- InformationUnit.Petabyte => (_value * 8d) * 1e15d,
+ InformationUnit.Petabyte => (_value * 8) * 1e15d,
InformationUnit.Tebibit => (_value) * (1024d * 1024 * 1024 * 1024),
- InformationUnit.Tebibyte => (_value * 8d) * (1024d * 1024 * 1024 * 1024),
+ InformationUnit.Tebibyte => (_value * 8) * (1024d * 1024 * 1024 * 1024),
InformationUnit.Terabit => (_value) * 1e12d,
- InformationUnit.Terabyte => (_value * 8d) * 1e12d,
+ InformationUnit.Terabyte => (_value * 8) * 1e12d,
_ => throw new NotImplementedException($"Can not convert {Unit} to base units.")
};
}
@@ -449,31 +449,31 @@ private double GetValueAs(InformationUnit unit)
return unit switch
{
InformationUnit.Bit => baseUnitValue,
- InformationUnit.Byte => baseUnitValue / 8d,
+ InformationUnit.Byte => baseUnitValue / 8,
InformationUnit.Exabit => (baseUnitValue) / 1e18d,
- InformationUnit.Exabyte => (baseUnitValue / 8d) / 1e18d,
+ InformationUnit.Exabyte => (baseUnitValue / 8) / 1e18d,
InformationUnit.Exbibit => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
- InformationUnit.Exbibyte => (baseUnitValue / 8d) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
+ InformationUnit.Exbibyte => (baseUnitValue / 8) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024),
InformationUnit.Gibibit => (baseUnitValue) / (1024d * 1024 * 1024),
- InformationUnit.Gibibyte => (baseUnitValue / 8d) / (1024d * 1024 * 1024),
+ InformationUnit.Gibibyte => (baseUnitValue / 8) / (1024d * 1024 * 1024),
InformationUnit.Gigabit => (baseUnitValue) / 1e9d,
- InformationUnit.Gigabyte => (baseUnitValue / 8d) / 1e9d,
+ InformationUnit.Gigabyte => (baseUnitValue / 8) / 1e9d,
InformationUnit.Kibibit => (baseUnitValue) / 1024d,
- InformationUnit.Kibibyte => (baseUnitValue / 8d) / 1024d,
+ InformationUnit.Kibibyte => (baseUnitValue / 8) / 1024d,
InformationUnit.Kilobit => (baseUnitValue) / 1e3d,
- InformationUnit.Kilobyte => (baseUnitValue / 8d) / 1e3d,
+ InformationUnit.Kilobyte => (baseUnitValue / 8) / 1e3d,
InformationUnit.Mebibit => (baseUnitValue) / (1024d * 1024),
- InformationUnit.Mebibyte => (baseUnitValue / 8d) / (1024d * 1024),
+ InformationUnit.Mebibyte => (baseUnitValue / 8) / (1024d * 1024),
InformationUnit.Megabit => (baseUnitValue) / 1e6d,
- InformationUnit.Megabyte => (baseUnitValue / 8d) / 1e6d,
+ InformationUnit.Megabyte => (baseUnitValue / 8) / 1e6d,
InformationUnit.Pebibit => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024),
- InformationUnit.Pebibyte => (baseUnitValue / 8d) / (1024d * 1024 * 1024 * 1024 * 1024),
+ InformationUnit.Pebibyte => (baseUnitValue / 8) / (1024d * 1024 * 1024 * 1024 * 1024),
InformationUnit.Petabit => (baseUnitValue) / 1e15d,
- InformationUnit.Petabyte => (baseUnitValue / 8d) / 1e15d,
+ InformationUnit.Petabyte => (baseUnitValue / 8) / 1e15d,
InformationUnit.Tebibit => (baseUnitValue) / (1024d * 1024 * 1024 * 1024),
- InformationUnit.Tebibyte => (baseUnitValue / 8d) / (1024d * 1024 * 1024 * 1024),
+ InformationUnit.Tebibyte => (baseUnitValue / 8) / (1024d * 1024 * 1024 * 1024),
InformationUnit.Terabit => (baseUnitValue) / 1e12d,
- InformationUnit.Terabyte => (baseUnitValue / 8d) / 1e12d,
+ InformationUnit.Terabyte => (baseUnitValue / 8) / 1e12d,
_ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.")
};
}
diff --git a/UnitsNet.Serialization.JsonNet.Tests/AbbreviatedUnitsConverterTests.cs b/UnitsNet.Serialization.JsonNet.Tests/AbbreviatedUnitsConverterTests.cs
index dbc17b3a18..10de4f9a3c 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/AbbreviatedUnitsConverterTests.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/AbbreviatedUnitsConverterTests.cs
@@ -1,5 +1,4 @@
-using System.Globalization;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
using UnitsNet.Tests.Serialization;
using UnitsNet.Units;
using Xunit;
@@ -25,21 +24,10 @@ public void DoubleQuantity_SerializedWithDoubleValueAndAbbreviatedUnit()
Assert.Equal(expectedJson, json);
}
- [Fact]
- public void DecimalQuantity_SerializedWithDecimalValueAndAbbreviatedUnit()
- {
- var quantity = new Information(1.20m, InformationUnit.Exabyte);
- var expectedJson = "{\"Value\":1.20,\"Unit\":\"EB\",\"Type\":\"Information\"}";
-
- var json = SerializeObject(quantity);
-
- Assert.Equal(expectedJson, json);
- }
-
[Fact]
public void InterfaceObject_IncludesTypeInformation()
{
- var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) };
+ var testObject = new TestInterfaceObject { Quantity = new Information(1.2, InformationUnit.Exabyte) };
var expectedJson = """{"Quantity":{"Value":1.2,"Unit":"EB","Type":"Information"}}""";
var json = SerializeObject(testObject);
@@ -84,7 +72,7 @@ public void DoubleQuantity_DeserializedFromDoubleValueAndAbbreviatedUnit()
Assert.Equal(1.2, quantity.Value);
Assert.Equal(MassUnit.Milligram, quantity.Unit);
}
-
+
[Fact]
public void DoubleIQuantity_DeserializedFromDoubleValueAndNonAmbiguousAbbreviatedUnit_WithoutQuantityType()
{
@@ -236,48 +224,44 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput()
[Fact]
public void DecimalIQuantity_DeserializedFromDecimalValueAndAbbreviatedUnit()
{
- var json = "{\"Value\":1.200,\"Unit\":\"EB\",\"Type\":\"Information\"}";
+ var json = """{"Value":1.200,"Unit":"EB","Type":"Information"}""";
var quantity = (Information) DeserializeObject(json);
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(1.200, quantity.Value);
Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
}
[Fact]
public void DecimalQuantity_DeserializedFromDecimalValueAndAbbreviatedUnit()
{
- var json = "{\"Value\":1.200,\"Unit\":\"EB\"}";
+ var json = """{"Value":1.200,"Unit":"EB"}""";
var quantity = DeserializeObject(json);
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(1.200, quantity.Value);
Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
}
[Fact]
public void DecimalIQuantity_DeserializedFromQuotedDecimalValueAndAbbreviatedUnit()
{
- var json = "{\"Value\":\"1.200\",\"Unit\":\"EB\",\"Type\":\"Information\"}";
+ var json = """{"Value":"1.200","Unit":"EB","Type":"Information"}""";
var quantity = (Information) DeserializeObject(json);
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(1.200, quantity.Value);
Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
}
[Fact]
public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndAbbreviatedUnit()
{
- var json = "{\"Value\":\"1.200\",\"Unit\":\"EB\"}";
+ var json = """{"Value":"1.200","Unit":"EB"}""";
var quantity = DeserializeObject(json);
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(1.200, quantity.Value);
Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
}
@@ -306,24 +290,22 @@ public void DecimalZeroQuantity_DeserializedFromAbbreviatedUnitAndNoValue()
[Fact]
public void DecimalBaseUnitIQuantity_DeserializedFromDecimalValueAndNoUnit()
{
- var json = "{\"Value\":1.200,\"Type\":\"Information\"}";
+ var json = """{"Value":1.200,"Type":"Information"}""";
var quantity = (Information)DeserializeObject(json);
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(1.200, quantity.Value);
Assert.Equal(Information.BaseUnit, quantity.Unit);
}
[Fact]
public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit()
{
- var json = "{\"Value\":1.200}";
+ var json = """{"Value":1.200}""";
var quantity = DeserializeObject(json);
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(1.200, quantity.Value);
Assert.Equal(Information.BaseUnit, quantity.Unit);
}
@@ -360,34 +342,13 @@ class PlainOldDoubleQuantity
public string Unit { get; set; }
}
- [JsonObject]
- class PlainOldDecimalQuantity
- {
- public decimal Value { get; set; }
- public string Unit { get; set; }
- }
-
- [Fact]
- public void LargeDecimalQuantity_DeserializedTo_PlainOldDecimalQuantity()
- {
- var quantity = new Information(2m * long.MaxValue, InformationUnit.Exabyte);
-
- var json = SerializeObject(quantity);
- var plainOldQuantity = JsonConvert.DeserializeObject(json);
-
- Assert.Equal(2m * long.MaxValue, plainOldQuantity.Value);
- Assert.Equal("EB", plainOldQuantity.Unit);
- }
-
[Fact]
public void LargeDecimalQuantity_DeserializedTo_PlainOldDoubleQuantity()
{
- var quantity = Information.FromExabytes(2m * long.MaxValue);
-
- var json = SerializeObject(quantity);
+ const string json = """{"Value":18446744073709551614,"Unit":"EB","Type":"Information"}""";
var plainOldQuantity = JsonConvert.DeserializeObject(json);
- Assert.Equal(2.0 * long.MaxValue, plainOldQuantity.Value);
+ Assert.Equal(18446744073709551614d, plainOldQuantity.Value);
Assert.Equal("EB", plainOldQuantity.Unit);
}
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs
index 8119df0815..ceb4481ec9 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs
@@ -30,15 +30,6 @@ public void UnitsNetBaseJsonConverter_ConvertIQuantity_works_with_double_type()
Assert.Equal(10.2365, result.Value);
}
- [Fact]
- public void UnitsNetBaseJsonConverter_ConvertIQuantity_works_with_decimal_type()
- {
- var result = _sut.Test_ConvertDecimalIQuantity(Information.FromBits(64m));
-
- Assert.Equal("InformationUnit.Bit", result.Unit);
- Assert.Equal(64m, result.Value);
- }
-
[Fact]
public void UnitsNetBaseJsonConverter_ConvertIQuantity_throws_ArgumentNullException_when_quantity_is_NULL()
{
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs
index aa0106de94..613f791cef 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs
@@ -68,23 +68,6 @@ public void UnitsNetIQuantityJsonConverter_WriteJson_works_with_double_quantity(
Assert.Equal("{\"Unit\":\"LengthUnit.Meter\",\"Value\":10.2365}", result.ToString());
}
- [Theory]
- [InlineData(10.2365, "10.2365", "10.2365")]
- [InlineData(10, "10.0", "10")] // Json.NET adds .0
- public void UnitsNetIQuantityJsonConverter_WriteJson_works_with_decimal_quantity(decimal value, string expectedValue, string expectedValueString)
- {
- var result = new StringBuilder();
-
- using (var stringWriter = new StringWriter(result))
- using(var writer = new JsonTextWriter(stringWriter))
- {
- _sut.WriteJson(writer, Information.FromBits(value), JsonSerializer.CreateDefault());
- }
-
- Assert.Equal($"{{\"Unit\":\"InformationUnit.Bit\",\"Value\":{expectedValue},\"ValueString\":\"{expectedValueString}\",\"ValueType\":\"decimal\"}}",
- result.ToString());
- }
-
[Fact]
public void UnitsNetIQuantityJsonConverter_CanRead_returns_true()
{
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs
index 0901a3dede..0660deb3f7 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs
@@ -1,7 +1,6 @@
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
-using System;
using Newtonsoft.Json;
using UnitsNet.Serialization.JsonNet.Tests.Infrastructure;
using UnitsNet.Units;
@@ -11,27 +10,6 @@ namespace UnitsNet.Serialization.JsonNet.Tests
{
public sealed class UnitsNetJsonDeserializationTests : UnitsNetJsonBaseTest
{
- [Fact]
- public void Information_CanDeserializeLargeValue()
- {
- var original = new Information(decimal.MaxValue, InformationUnit.Exbibyte);
- var json = SerializeObject(original);
- var deserialized = DeserializeObject(json);
-
- Assert.Equal(original, deserialized);
- }
-
- [Fact]
- public void Information_CanDeserializeSmallValue()
- {
- decimal decimalEpsilon = (decimal)(1 / Math.Pow(10, 28));
- var original = new Information(decimalEpsilon, InformationUnit.Bit);
- var json = SerializeObject(original);
- var deserialized = DeserializeObject(json);
-
- Assert.Equal(original, deserialized);
- }
-
[Fact]
public void Length_CanDeserializeLargeValue()
{
@@ -302,5 +280,53 @@ public void EmptyArray_ExpectCorrectlyDeserialized()
Assert.Empty(result);
}
+
+ ///
+ /// Testing deserialization of JSON, based on .
+ ///
+ [Fact]
+ public void CanDeserializeDoubleQuantityJson()
+ {
+ const string json =
+ """
+ {
+ "Unit": "LengthUnit.Centimeter",
+ "Value": 10.5,
+ }
+ """;
+
+ Length deserialized = DeserializeObject(json);
+ Assert.Equal(10.5, deserialized.Value);
+ Assert.Equal(LengthUnit.Centimeter, deserialized.Unit);
+ }
+
+ ///
+ /// Testing backwards compatibility with deserializing based quantity JSON into based quantities.
+ ///
+ /// In v5 and below, there were 3 based quantities , and .
+ /// Since JSON does not support decimal values, the JSON schema emitted the value as a string instead of a number and included a 'ValueType'
+ /// discriminator to describe whether the value was double or decimal.
+ ///
+ /// based quantities were serialized with DTO, with double Value + string Unit properties.
+ /// based quantities were serialized with DTO, extending with ValueString and ValueType properties.
+ ///
+ [Fact]
+ public void CanDeserializeLegacyDecimalQuantityJson()
+ {
+ const string json =
+ """
+ {
+ "Unit": "InformationUnit.Kilobyte",
+ "Value": 10.5,
+ "ValueString": "10.5",
+ "ValueType": "decimal"
+ }
+ """;
+
+ Information deserialized = DeserializeObject(json);
+ Assert.Equal(10.5, deserialized.Value);
+ Assert.Equal(InformationUnit.Kilobyte, deserialized.Unit);
+ }
+
}
}
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs
index 8d8d6b2e35..ea72ae3c67 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs
@@ -12,7 +12,7 @@ public sealed class UnitsNetJsonSerializationTests : UnitsNetJsonBaseTest
public void Information_CanSerializeVeryLargeValues()
{
Information i = Information.FromExabytes(1E+9);
- var expectedJson = "{\n \"Unit\": \"InformationUnit.Exabyte\",\n \"Value\": 1000000000.0,\n \"ValueString\": \"1000000000\",\n \"ValueType\": \"decimal\"\n}";
+ var expectedJson = "{\n \"Unit\": \"InformationUnit.Exabyte\",\n \"Value\": 1000000000.0\n}";
string json = SerializeObject(i);
@@ -34,7 +34,7 @@ public void Mass_ExpectConstructedValueAndUnit()
public void Information_ExpectConstructedValueAndUnit()
{
Information quantity = Information.FromKilobytes(54);
- var expectedJson = "{\n \"Unit\": \"InformationUnit.Kilobyte\",\n \"Value\": 54.0,\n \"ValueString\": \"54\",\n \"ValueType\": \"decimal\"\n}";
+ var expectedJson = "{\n \"Unit\": \"InformationUnit.Kilobyte\",\n \"Value\": 54.0\n}";
string json = SerializeObject(quantity);
diff --git a/UnitsNet.Tests/CustomCode/BitRateTests.cs b/UnitsNet.Tests/CustomCode/BitRateTests.cs
index 5e49dc8ad3..e320ca2985 100644
--- a/UnitsNet.Tests/CustomCode/BitRateTests.cs
+++ b/UnitsNet.Tests/CustomCode/BitRateTests.cs
@@ -29,37 +29,37 @@ public class BitRateTests : BitRateTestsBase
{
protected override bool SupportsSIUnitSystem => false;
- protected override decimal BitsPerSecondInOneBitPerSecond => 1m;
- protected override decimal BytesPerSecondInOneBitPerSecond => 1.25E-1m;
+ protected override double BitsPerSecondInOneBitPerSecond => 1;
+ protected override double BytesPerSecondInOneBitPerSecond => 1.25E-1;
- protected override decimal KilobitsPerSecondInOneBitPerSecond => 1E-3m;
- protected override decimal KilobytesPerSecondInOneBitPerSecond => 1.25E-4m;
- protected override decimal KibibitsPerSecondInOneBitPerSecond => 0.0009765625m;
- protected override decimal KibibytesPerSecondInOneBitPerSecond => 0.0001220703125m;
+ protected override double KilobitsPerSecondInOneBitPerSecond => 1E-3;
+ protected override double KilobytesPerSecondInOneBitPerSecond => 1.25E-4;
+ protected override double KibibitsPerSecondInOneBitPerSecond => 0.0009765625;
+ protected override double KibibytesPerSecondInOneBitPerSecond => 0.0001220703125;
- protected override decimal MegabitsPerSecondInOneBitPerSecond => 1E-6m;
- protected override decimal MegabytesPerSecondInOneBitPerSecond => 1.25E-07m;
- protected override decimal MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07m;
- protected override decimal MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07m;
+ protected override double MegabitsPerSecondInOneBitPerSecond => 1E-6;
+ protected override double MegabytesPerSecondInOneBitPerSecond => 1.25E-07;
+ protected override double MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07;
+ protected override double MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07;
- protected override decimal GigabitsPerSecondInOneBitPerSecond => 1E-9m;
- protected override decimal GigabytesPerSecondInOneBitPerSecond => 1.25E-10m;
- protected override decimal GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10m;
- protected override decimal GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10m;
+ protected override double GigabitsPerSecondInOneBitPerSecond => 1E-9;
+ protected override double GigabytesPerSecondInOneBitPerSecond => 1.25E-10;
+ protected override double GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10;
+ protected override double GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10;
- protected override decimal TerabitsPerSecondInOneBitPerSecond => 1E-12m;
- protected override decimal TerabytesPerSecondInOneBitPerSecond => 1.25E-13m;
- protected override decimal TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13m;
- protected override decimal TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13m;
+ protected override double TerabitsPerSecondInOneBitPerSecond => 1E-12;
+ protected override double TerabytesPerSecondInOneBitPerSecond => 1.25E-13;
+ protected override double TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13;
+ protected override double TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13;
- protected override decimal PetabitsPerSecondInOneBitPerSecond => 1E-15m;
- protected override decimal PetabytesPerSecondInOneBitPerSecond => 1.25E-16m;
- protected override decimal PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16m;
- protected override decimal PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16m;
+ protected override double PetabitsPerSecondInOneBitPerSecond => 1E-15;
+ protected override double PetabytesPerSecondInOneBitPerSecond => 1.25E-16;
+ protected override double PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16;
+ protected override double PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16;
- protected override decimal ExabitsPerSecondInOneBitPerSecond => 1E-18m;
- protected override decimal ExabytesPerSecondInOneBitPerSecond => 1.25E-19m;
- protected override decimal ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19m;
- protected override decimal ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19m;
+ protected override double ExabitsPerSecondInOneBitPerSecond => 1E-18;
+ protected override double ExabytesPerSecondInOneBitPerSecond => 1.25E-19;
+ protected override double ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19;
+ protected override double ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19;
}
}
diff --git a/UnitsNet.Tests/CustomCode/IQuantityTests.cs b/UnitsNet.Tests/CustomCode/IQuantityTests.cs
index abae93ba96..6333011d83 100644
--- a/UnitsNet.Tests/CustomCode/IQuantityTests.cs
+++ b/UnitsNet.Tests/CustomCode/IQuantityTests.cs
@@ -79,19 +79,5 @@ public void IQuantityTUnitDouble_AsUnitSystem_ReturnsDouble()
IQuantity doubleQuantity = Temperature.FromDegreesCelsius(1234.5);
Assert.IsType(doubleQuantity.As(UnitSystem.SI));
}
-
- [Fact]
- public void IQuantityTUnitDecimal_Value_ReturnsDecimal()
- {
- IQuantity decimalQuantity = Information.FromKilobytes(1234.5);
- Assert.IsType(decimalQuantity.Value);
- }
-
- [Fact]
- public void IQuantityTUnitDecimal_AsEnum_ReturnsDecimal()
- {
- IQuantity decimalQuantity = Information.FromKilobytes(1234.5);
- Assert.IsType(decimalQuantity.As(InformationUnit.Byte));
- }
}
}
diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs
index 909a1ac9c5..b99dac5b37 100644
--- a/UnitsNet.Tests/CustomCode/InformationTests.cs
+++ b/UnitsNet.Tests/CustomCode/InformationTests.cs
@@ -9,57 +9,57 @@ namespace UnitsNet.Tests
public class InformationTests : InformationTestsBase
{
protected override bool SupportsSIUnitSystem => false;
- protected override decimal BitsInOneBit => 1m;
+ protected override double BitsInOneBit => 1;
- protected override decimal BytesInOneBit => 0.125m;
+ protected override double BytesInOneBit => 0.125;
- protected override decimal ExabitsInOneBit => 1e-18m;
+ protected override double ExabitsInOneBit => 1e-18;
- protected override decimal ExabytesInOneBit => 0.125m*1e-18m;
+ protected override double ExabytesInOneBit => 0.125*1e-18;
- protected override decimal ExbibitsInOneBit => 1m/(decimal)Math.Pow(1024, 6);
+ protected override double ExbibitsInOneBit => 1d/Math.Pow(1024, 6);
- protected override decimal ExbibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 6);
+ protected override double ExbibytesInOneBit => 1d/8/Math.Pow(1024, 6);
- protected override decimal GibibitsInOneBit => 1m/(decimal)Math.Pow(1024, 3);
+ protected override double GibibitsInOneBit => 1d/Math.Pow(1024, 3);
- protected override decimal GibibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 3);
+ protected override double GibibytesInOneBit => 1d/8/Math.Pow(1024, 3);
- protected override decimal GigabitsInOneBit => 1e-9m;
+ protected override double GigabitsInOneBit => 1e-9;
- protected override decimal GigabytesInOneBit => 0.125m*1e-9m;
+ protected override double GigabytesInOneBit => 0.125*1e-9;
- protected override decimal KibibitsInOneBit => 1m/1024m;
+ protected override double KibibitsInOneBit => 1d/1024;
- protected override decimal KibibytesInOneBit => 1m/8/1024m;
+ protected override double KibibytesInOneBit => 1d/8/1024;
- protected override decimal KilobitsInOneBit => 0.001m;
+ protected override double KilobitsInOneBit => 0.001;
- protected override decimal KilobytesInOneBit => 0.000125m;
+ protected override double KilobytesInOneBit => 0.000125;
- protected override decimal MebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 2);
+ protected override double MebibitsInOneBit => 1d/Math.Pow(1024, 2);
- protected override decimal MebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 2);
+ protected override double MebibytesInOneBit => 1d/8/Math.Pow(1024, 2);
- protected override decimal MegabitsInOneBit => 1e-6m;
+ protected override double MegabitsInOneBit => 1e-6;
- protected override decimal MegabytesInOneBit => 0.125m*1e-6m;
+ protected override double MegabytesInOneBit => 0.125*1e-6;
- protected override decimal PebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 5);
+ protected override double PebibitsInOneBit => 1d/Math.Pow(1024, 5);
- protected override decimal PebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 5);
+ protected override double PebibytesInOneBit => 1d/8/Math.Pow(1024, 5);
- protected override decimal PetabitsInOneBit => 1e-15m;
+ protected override double PetabitsInOneBit => 1e-15;
- protected override decimal PetabytesInOneBit => 0.125m*1e-15m;
+ protected override double PetabytesInOneBit => 0.125*1e-15;
- protected override decimal TebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 4);
+ protected override double TebibitsInOneBit => 1d/Math.Pow(1024, 4);
- protected override decimal TebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 4);
+ protected override double TebibytesInOneBit => 1d/8/Math.Pow(1024, 4);
- protected override decimal TerabitsInOneBit => 1e-12m;
+ protected override double TerabitsInOneBit => 1e-12;
- protected override decimal TerabytesInOneBit => 0.125m*1e-12m;
+ protected override double TerabytesInOneBit => 0.125*1e-12;
[Fact]
public void OneKBHas1000Bytes()
diff --git a/UnitsNet.Tests/CustomCode/ParseTests.cs b/UnitsNet.Tests/CustomCode/ParseTests.cs
index c061975ce6..9bb2f3f302 100644
--- a/UnitsNet.Tests/CustomCode/ParseTests.cs
+++ b/UnitsNet.Tests/CustomCode/ParseTests.cs
@@ -202,7 +202,7 @@ public void ParseForceWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAn
[InlineData("1 MB", "ru-RU", 1, InformationUnit.Megabyte)]
[InlineData("1 MiB", "en-US", 1, InformationUnit.Mebibyte)]
[InlineData("1 MiB", "ru-RU", 1, InformationUnit.Mebibyte)]
- public void ParseInformationWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue(string str, string cultureName, decimal expectedValue, Enum expectedUnit)
+ public void ParseInformationWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue(string str, string cultureName, double expectedValue, Enum expectedUnit)
{
var actual = Information.Parse(str, CultureInfo.GetCultureInfo(cultureName));
diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs
index be62ba4cc7..c375ba78b6 100644
--- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs
@@ -38,63 +38,63 @@ namespace UnitsNet.Tests
// ReSharper disable once PartialTypeWithSinglePart
public abstract partial class BitRateTestsBase : QuantityTestsBase
{
- protected abstract decimal BitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal BytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal ExabitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal ExabytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal ExbibitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal ExbibytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal GibibitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal GibibytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal GigabitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal GigabytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal KibibitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal KibibytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal KilobitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal KilobytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal MebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal MebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal MegabitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal MegabytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal PebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal PebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal PetabitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal PetabytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal TebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal TebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract decimal TerabitsPerSecondInOneBitPerSecond { get; }
- protected abstract decimal TerabytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double BitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double BytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double ExabitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double ExabytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double GibibitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double GibibytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double GigabitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double GigabytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double KibibitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double KibibytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double KilobitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double KilobytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double MebibitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double MebibytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double MegabitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double MegabytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double PebibitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double PebibytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double PetabitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double PetabytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double TebibitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double TebibytesPerSecondInOneBitPerSecond { get; }
+ protected abstract double TerabitsPerSecondInOneBitPerSecond { get; }
+ protected abstract double TerabytesPerSecondInOneBitPerSecond { get; }
// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual decimal BitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal BytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal ExabitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal ExabytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal ExbibitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal ExbibytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal GibibitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal GibibytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal GigabitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal GigabytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal KibibitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal KibibytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal KilobitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal KilobytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal MebibitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal MebibytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal MegabitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal MegabytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal PebibitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal PebibytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal PetabitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal PetabytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal TebibitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal TebibytesPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal TerabitsPerSecondTolerance { get { return 1e-9m; } }
- protected virtual decimal TerabytesPerSecondTolerance { get { return 1e-9m; } }
+ protected virtual double BitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double BytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } }
+ protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } }
// ReSharper restore VirtualMemberNeverOverriden.Global
- protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(BitRateUnit unit)
+ protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BitRateUnit unit)
{
return unit switch
{
@@ -163,10 +163,27 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
{
var quantity = new BitRate();
Assert.Equal(0, quantity.Value);
- Assert.Equal(0m, ((IValueQuantity)quantity).Value);
Assert.Equal(BitRateUnit.BitPerSecond, quantity.Unit);
}
+ [Fact]
+ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => new BitRate(double.PositiveInfinity, BitRateUnit.BitPerSecond));
+ var exception2 = Record.Exception(() => new BitRate(double.NegativeInfinity, BitRateUnit.BitPerSecond));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void Ctor_WithNaNValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => new BitRate(double.NaN, BitRateUnit.BitPerSecond));
+
+ Assert.Null(exception);
+ }
+
[Fact]
public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException()
{
@@ -343,6 +360,24 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
}
+ [Fact]
+ public void FromBitsPerSecond_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => BitRate.FromBitsPerSecond(double.PositiveInfinity));
+ var exception2 = Record.Exception(() => BitRate.FromBitsPerSecond(double.NegativeInfinity));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void FromBitsPerSecond_WithNanValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => BitRate.FromBitsPerSecond(double.NaN));
+
+ Assert.Null(exception);
+ }
+
[Fact]
public void As()
{
@@ -1480,7 +1515,7 @@ public void CompareToThrowsOnNull()
[InlineData(1, BitRateUnit.BitPerSecond, 2, BitRateUnit.BitPerSecond, false)] // Different value.
[InlineData(2, BitRateUnit.BitPerSecond, 1, BitRateUnit.BytePerSecond, false)] // Different value and unit.
[InlineData(1, BitRateUnit.BitPerSecond, 1, BitRateUnit.BytePerSecond, false)] // Different unit.
- public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(decimal valueA, BitRateUnit unitA, decimal valueB, BitRateUnit unitB, bool expectEqual)
+ public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, BitRateUnit unitA, double valueB, BitRateUnit unitB, bool expectEqual)
{
var a = new BitRate(valueA, unitA);
var b = new BitRate(valueB, unitB);
@@ -1641,10 +1676,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul
try
{
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
- Assert.Equal("0.1 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s1"));
- Assert.Equal("0.12 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s2"));
- Assert.Equal("0.123 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s3"));
- Assert.Equal("0.1235 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s4"));
+ Assert.Equal("0.1 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s1"));
+ Assert.Equal("0.12 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s2"));
+ Assert.Equal("0.123 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s3"));
+ Assert.Equal("0.1235 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s4"));
}
finally
{
@@ -1656,10 +1691,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul
public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture()
{
var culture = CultureInfo.InvariantCulture;
- Assert.Equal("0.1 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s1", culture));
- Assert.Equal("0.12 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s2", culture));
- Assert.Equal("0.123 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s3", culture));
- Assert.Equal("0.1235 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s4", culture));
+ Assert.Equal("0.1 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s1", culture));
+ Assert.Equal("0.12 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s2", culture));
+ Assert.Equal("0.123 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s3", culture));
+ Assert.Equal("0.1235 bit/s", new BitRate(0.123456, BitRateUnit.BitPerSecond).ToString("s4", culture));
}
[Theory]
diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs
index f061b4eca8..dc482d26f1 100644
--- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs
@@ -38,63 +38,63 @@ namespace UnitsNet.Tests
// ReSharper disable once PartialTypeWithSinglePart
public abstract partial class InformationTestsBase : QuantityTestsBase
{
- protected abstract decimal BitsInOneBit { get; }
- protected abstract decimal BytesInOneBit { get; }
- protected abstract decimal ExabitsInOneBit { get; }
- protected abstract decimal ExabytesInOneBit { get; }
- protected abstract decimal ExbibitsInOneBit { get; }
- protected abstract decimal ExbibytesInOneBit { get; }
- protected abstract decimal GibibitsInOneBit { get; }
- protected abstract decimal GibibytesInOneBit { get; }
- protected abstract decimal GigabitsInOneBit { get; }
- protected abstract decimal GigabytesInOneBit { get; }
- protected abstract decimal KibibitsInOneBit { get; }
- protected abstract decimal KibibytesInOneBit { get; }
- protected abstract decimal KilobitsInOneBit { get; }
- protected abstract decimal KilobytesInOneBit { get; }
- protected abstract decimal MebibitsInOneBit { get; }
- protected abstract decimal MebibytesInOneBit { get; }
- protected abstract decimal MegabitsInOneBit { get; }
- protected abstract decimal MegabytesInOneBit { get; }
- protected abstract decimal PebibitsInOneBit { get; }
- protected abstract decimal PebibytesInOneBit { get; }
- protected abstract decimal PetabitsInOneBit { get; }
- protected abstract decimal PetabytesInOneBit { get; }
- protected abstract decimal TebibitsInOneBit { get; }
- protected abstract decimal TebibytesInOneBit { get; }
- protected abstract decimal TerabitsInOneBit { get; }
- protected abstract decimal TerabytesInOneBit { get; }
+ protected abstract double BitsInOneBit { get; }
+ protected abstract double BytesInOneBit { get; }
+ protected abstract double ExabitsInOneBit { get; }
+ protected abstract double ExabytesInOneBit { get; }
+ protected abstract double ExbibitsInOneBit { get; }
+ protected abstract double ExbibytesInOneBit { get; }
+ protected abstract double GibibitsInOneBit { get; }
+ protected abstract double GibibytesInOneBit { get; }
+ protected abstract double GigabitsInOneBit { get; }
+ protected abstract double GigabytesInOneBit { get; }
+ protected abstract double KibibitsInOneBit { get; }
+ protected abstract double KibibytesInOneBit { get; }
+ protected abstract double KilobitsInOneBit { get; }
+ protected abstract double KilobytesInOneBit { get; }
+ protected abstract double MebibitsInOneBit { get; }
+ protected abstract double MebibytesInOneBit { get; }
+ protected abstract double MegabitsInOneBit { get; }
+ protected abstract double MegabytesInOneBit { get; }
+ protected abstract double PebibitsInOneBit { get; }
+ protected abstract double PebibytesInOneBit { get; }
+ protected abstract double PetabitsInOneBit { get; }
+ protected abstract double PetabytesInOneBit { get; }
+ protected abstract double TebibitsInOneBit { get; }
+ protected abstract double TebibytesInOneBit { get; }
+ protected abstract double TerabitsInOneBit { get; }
+ protected abstract double TerabytesInOneBit { get; }
// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual decimal BitsTolerance { get { return 1e-9m; } }
- protected virtual decimal BytesTolerance { get { return 1e-9m; } }
- protected virtual decimal ExabitsTolerance { get { return 1e-9m; } }
- protected virtual decimal ExabytesTolerance { get { return 1e-9m; } }
- protected virtual decimal ExbibitsTolerance { get { return 1e-9m; } }
- protected virtual decimal ExbibytesTolerance { get { return 1e-9m; } }
- protected virtual decimal GibibitsTolerance { get { return 1e-9m; } }
- protected virtual decimal GibibytesTolerance { get { return 1e-9m; } }
- protected virtual decimal GigabitsTolerance { get { return 1e-9m; } }
- protected virtual decimal GigabytesTolerance { get { return 1e-9m; } }
- protected virtual decimal KibibitsTolerance { get { return 1e-9m; } }
- protected virtual decimal KibibytesTolerance { get { return 1e-9m; } }
- protected virtual decimal KilobitsTolerance { get { return 1e-9m; } }
- protected virtual decimal KilobytesTolerance { get { return 1e-9m; } }
- protected virtual decimal MebibitsTolerance { get { return 1e-9m; } }
- protected virtual decimal MebibytesTolerance { get { return 1e-9m; } }
- protected virtual decimal MegabitsTolerance { get { return 1e-9m; } }
- protected virtual decimal MegabytesTolerance { get { return 1e-9m; } }
- protected virtual decimal PebibitsTolerance { get { return 1e-9m; } }
- protected virtual decimal PebibytesTolerance { get { return 1e-9m; } }
- protected virtual decimal PetabitsTolerance { get { return 1e-9m; } }
- protected virtual decimal PetabytesTolerance { get { return 1e-9m; } }
- protected virtual decimal TebibitsTolerance { get { return 1e-9m; } }
- protected virtual decimal TebibytesTolerance { get { return 1e-9m; } }
- protected virtual decimal TerabitsTolerance { get { return 1e-9m; } }
- protected virtual decimal TerabytesTolerance { get { return 1e-9m; } }
+ protected virtual double BitsTolerance { get { return 1e-5; } }
+ protected virtual double BytesTolerance { get { return 1e-5; } }
+ protected virtual double ExabitsTolerance { get { return 1e-5; } }
+ protected virtual double ExabytesTolerance { get { return 1e-5; } }
+ protected virtual double ExbibitsTolerance { get { return 1e-5; } }
+ protected virtual double ExbibytesTolerance { get { return 1e-5; } }
+ protected virtual double GibibitsTolerance { get { return 1e-5; } }
+ protected virtual double GibibytesTolerance { get { return 1e-5; } }
+ protected virtual double GigabitsTolerance { get { return 1e-5; } }
+ protected virtual double GigabytesTolerance { get { return 1e-5; } }
+ protected virtual double KibibitsTolerance { get { return 1e-5; } }
+ protected virtual double KibibytesTolerance { get { return 1e-5; } }
+ protected virtual double KilobitsTolerance { get { return 1e-5; } }
+ protected virtual double KilobytesTolerance { get { return 1e-5; } }
+ protected virtual double MebibitsTolerance { get { return 1e-5; } }
+ protected virtual double MebibytesTolerance { get { return 1e-5; } }
+ protected virtual double MegabitsTolerance { get { return 1e-5; } }
+ protected virtual double MegabytesTolerance { get { return 1e-5; } }
+ protected virtual double PebibitsTolerance { get { return 1e-5; } }
+ protected virtual double PebibytesTolerance { get { return 1e-5; } }
+ protected virtual double PetabitsTolerance { get { return 1e-5; } }
+ protected virtual double PetabytesTolerance { get { return 1e-5; } }
+ protected virtual double TebibitsTolerance { get { return 1e-5; } }
+ protected virtual double TebibytesTolerance { get { return 1e-5; } }
+ protected virtual double TerabitsTolerance { get { return 1e-5; } }
+ protected virtual double TerabytesTolerance { get { return 1e-5; } }
// ReSharper restore VirtualMemberNeverOverriden.Global
- protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(InformationUnit unit)
+ protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(InformationUnit unit)
{
return unit switch
{
@@ -163,10 +163,27 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
{
var quantity = new Information();
Assert.Equal(0, quantity.Value);
- Assert.Equal(0m, ((IValueQuantity)quantity).Value);
Assert.Equal(InformationUnit.Bit, quantity.Unit);
}
+ [Fact]
+ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => new Information(double.PositiveInfinity, InformationUnit.Bit));
+ var exception2 = Record.Exception(() => new Information(double.NegativeInfinity, InformationUnit.Bit));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void Ctor_WithNaNValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => new Information(double.NaN, InformationUnit.Bit));
+
+ Assert.Null(exception);
+ }
+
[Fact]
public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException()
{
@@ -343,6 +360,24 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
}
+ [Fact]
+ public void FromBits_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => Information.FromBits(double.PositiveInfinity));
+ var exception2 = Record.Exception(() => Information.FromBits(double.NegativeInfinity));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void FromBits_WithNanValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => Information.FromBits(double.NaN));
+
+ Assert.Null(exception);
+ }
+
[Fact]
public void As()
{
@@ -882,7 +917,7 @@ public void CompareToThrowsOnNull()
[InlineData(1, InformationUnit.Bit, 2, InformationUnit.Bit, false)] // Different value.
[InlineData(2, InformationUnit.Bit, 1, InformationUnit.Byte, false)] // Different value and unit.
[InlineData(1, InformationUnit.Bit, 1, InformationUnit.Byte, false)] // Different unit.
- public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(decimal valueA, InformationUnit unitA, decimal valueB, InformationUnit unitB, bool expectEqual)
+ public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, InformationUnit unitA, double valueB, InformationUnit unitB, bool expectEqual)
{
var a = new Information(valueA, unitA);
var b = new Information(valueB, unitB);
@@ -1043,10 +1078,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul
try
{
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
- Assert.Equal("0.1 b", new Information(0.123456m, InformationUnit.Bit).ToString("s1"));
- Assert.Equal("0.12 b", new Information(0.123456m, InformationUnit.Bit).ToString("s2"));
- Assert.Equal("0.123 b", new Information(0.123456m, InformationUnit.Bit).ToString("s3"));
- Assert.Equal("0.1235 b", new Information(0.123456m, InformationUnit.Bit).ToString("s4"));
+ Assert.Equal("0.1 b", new Information(0.123456, InformationUnit.Bit).ToString("s1"));
+ Assert.Equal("0.12 b", new Information(0.123456, InformationUnit.Bit).ToString("s2"));
+ Assert.Equal("0.123 b", new Information(0.123456, InformationUnit.Bit).ToString("s3"));
+ Assert.Equal("0.1235 b", new Information(0.123456, InformationUnit.Bit).ToString("s4"));
}
finally
{
@@ -1058,10 +1093,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul
public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture()
{
var culture = CultureInfo.InvariantCulture;
- Assert.Equal("0.1 b", new Information(0.123456m, InformationUnit.Bit).ToString("s1", culture));
- Assert.Equal("0.12 b", new Information(0.123456m, InformationUnit.Bit).ToString("s2", culture));
- Assert.Equal("0.123 b", new Information(0.123456m, InformationUnit.Bit).ToString("s3", culture));
- Assert.Equal("0.1235 b", new Information(0.123456m, InformationUnit.Bit).ToString("s4", culture));
+ Assert.Equal("0.1 b", new Information(0.123456, InformationUnit.Bit).ToString("s1", culture));
+ Assert.Equal("0.12 b", new Information(0.123456, InformationUnit.Bit).ToString("s2", culture));
+ Assert.Equal("0.123 b", new Information(0.123456, InformationUnit.Bit).ToString("s3", culture));
+ Assert.Equal("0.1235 b", new Information(0.123456, InformationUnit.Bit).ToString("s4", culture));
}
[Theory]
diff --git a/UnitsNet.Tests/GenericMathExtensionsTests.cs b/UnitsNet.Tests/GenericMathExtensionsTests.cs
index cea65470bb..820f338f0a 100644
--- a/UnitsNet.Tests/GenericMathExtensionsTests.cs
+++ b/UnitsNet.Tests/GenericMathExtensionsTests.cs
@@ -24,14 +24,6 @@ public void CanCalcAverage_ForQuantitiesWithDoubleValueType()
Assert.Equal(Length.FromCentimeters(150), values.Average());
}
-
- [Fact]
- public void CanCalcAverage_ForQuantitiesWithDecimalValueType()
- {
- Information[] values = { Information.FromBytes(100), Information.FromBytes(200) };
-
- Assert.Equal(Information.FromBytes(150), values.Average());
- }
}
#endif
diff --git a/UnitsNet.Tests/IValueQuantityTests.cs b/UnitsNet.Tests/IValueQuantityTests.cs
index a0a8a1b318..ae8783c87b 100644
--- a/UnitsNet.Tests/IValueQuantityTests.cs
+++ b/UnitsNet.Tests/IValueQuantityTests.cs
@@ -30,20 +30,6 @@ public void IValueQuantityTDouble_AsUnitSystem_ReturnsDouble()
Assert.IsType(doubleQuantity.As(UnitSystem.SI));
}
- [Fact]
- public void IValueQuantityTDecimal_Value_ReturnsDecimal()
- {
- IValueQuantity decimalQuantity = Information.FromKilobytes(1234.5);
- Assert.IsType(decimalQuantity.Value);
- }
-
- [Fact]
- public void IValueQuantityTDecimal_AsEnum_ReturnsDecimal()
- {
- IValueQuantity decimalQuantity = Information.FromKilobytes(1234.5);
- Assert.IsType(decimalQuantity.As(InformationUnit.Byte));
- }
-
[Fact]
public void IValueQuantityTDouble_ToUnitEnum_ReturnsIValueQuantityTDouble()
{
@@ -57,12 +43,5 @@ public void IValueQuantityTDouble_ToUnitUnitSystem_ReturnsIValueQuantityTDouble(
IValueQuantity doubleQuantity = Temperature.FromDegreesCelsius(1234.5);
Assert.IsAssignableFrom>(doubleQuantity.ToUnit(UnitSystem.SI));
}
-
- [Fact]
- public void IValueQuantityTDecimal_ToUnitEnum_ReturnsIValueQuantityTDecimal()
- {
- IValueQuantity decimalQuantity = Information.FromKilobytes(1234.5);
- Assert.IsAssignableFrom>(decimalQuantity.ToUnit(InformationUnit.Bit));
- }
}
}
diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs
index 341687d29e..3f4eaaea1e 100644
--- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs
+++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs
@@ -54,18 +54,6 @@ public void DoubleQuantity_SerializedWithDoubleValueAndunitInt()
Assert.Equal(expectedJson, json);
}
- [Fact]
- public void DecimalQuantity_SerializedWithDecimalValueValueAndunitInt()
- {
- var quantity = new Information(1.20m, InformationUnit.Exabyte);
- var unitInt = (int)InformationUnit.Exabyte;
- var expectedJson = $"{{\"Value\":1.20,\"Unit\":{unitInt}}}";
-
- var json = SerializeObject(quantity);
-
- Assert.Equal(expectedJson, json);
- }
-
#endregion
#region Deserialization tests
@@ -114,8 +102,8 @@ public void InterfaceObject_IncludesTypeInformation()
{
var unit = InformationUnit.Exabyte;
var unitInt = (int)unit;
- var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, unit) };
- var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":{unitInt}}}}}";
+ var testObject = new TestInterfaceObject { Quantity = new Information(1.2, unit) };
+ var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":1.2,\"Unit\":{unitInt}}}}}";
var json = SerializeObject(testObject);
@@ -144,20 +132,6 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput()
Assert.Equal(Mass.BaseUnit, quantity.Unit);
}
- [Fact]
- public void DecimalQuantity_DeserializedFromDecimalValueAndUnitInt()
- {
- var expectedUnit = InformationUnit.Exabyte;
- var unitInt = (int)expectedUnit;
- var json = $"{{\"Value\":1.200,\"Unit\":{unitInt}}}";
-
- var quantity = DeserializeObject(json);
-
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
- Assert.Equal(expectedUnit, quantity.Unit);
- }
-
[Fact]
public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationException()
{
@@ -166,20 +140,6 @@ public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationE
Assert.Throws(() => SerializeObject(testObject));
}
- [Fact]
- public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndUnitInt()
- {
- var expectedUnit = InformationUnit.Exabyte;
- var unitInt = (int)expectedUnit;
- var json = $"{{\"Value\":\"1.200\",\"Unit\":{unitInt}}}";
-
- var quantity = DeserializeObject(json);
-
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
- Assert.Equal(expectedUnit, quantity.Unit);
- }
-
[Fact]
public void DecimalZeroQuantity_DeserializedFromUnitIntAndNoValue()
{
@@ -193,18 +153,6 @@ public void DecimalZeroQuantity_DeserializedFromUnitIntAndNoValue()
Assert.Equal(expectedUnit, quantity.Unit);
}
- [Fact]
- public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit()
- {
- var json = "{\"Value\":1.200}";
-
- var quantity = DeserializeObject(json);
-
- Assert.Equal(1.200m, quantity.Value);
- Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
- Assert.Equal(Information.BaseUnit, quantity.Unit);
- }
-
[Fact]
public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput()
{
diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs
index 476cac8173..4a8e99e772 100644
--- a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs
+++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
using System.Runtime.Serialization;
using UnitsNet.Units;
using Xunit;
@@ -47,20 +46,6 @@ public void DoubleValueQuantity_SerializationRoundTrips(double value)
Assert.Equal(quantity, result);
}
- [Fact]
- public void DecimalValueQuantity_SerializationRoundTrips()
- {
- var quantity = Information.FromExabytes(1.200m);
-
- var payload = SerializeObject(quantity);
- var result = DeserializeObject(payload);
-
- Assert.Equal(quantity.Unit, result.Unit);
- Assert.Equal(quantity.Value, result.Value);
- Assert.Equal(quantity, result);
- Assert.Equal("1.200", result.Value.ToString(CultureInfo.InvariantCulture));
- }
-
[Fact]
public void LargeDecimalValueQuantity_SerializationRoundTrips()
{
@@ -94,28 +79,6 @@ public void ArrayOfDoubleValueQuantities_SerializationRoundTrips()
});
}
- [Fact]
- [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")]
- public void ArrayOfDecimalValueQuantities_SerializationRoundTrips()
- {
- var quantities = new[] { new Information(1.2m, InformationUnit.Exabit), new Information(2, InformationUnit.Exabyte) };
-
- var payload = SerializeObject(quantities);
- var results = DeserializeObject(payload);
-
- Assert.Collection(results, result =>
- {
- Assert.Equal(quantities[0].Unit, result.Unit);
- Assert.Equal(quantities[0].Value, result.Value);
- Assert.Equal(quantities[0], result);
- }, result =>
- {
- Assert.Equal(quantities[1].Unit, result.Unit);
- Assert.Equal(quantities[1].Value, result.Value);
- Assert.Equal(quantities[1], result);
- });
- }
-
[Fact]
public void EmptyArray_RoundTripsEmpty()
{
@@ -150,30 +113,6 @@ public virtual void EnumerableOfDoubleValueQuantities_SerializationRoundTrips()
});
}
- [Fact]
- [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")]
- public virtual void EnumerableOfDecimalValueQuantities_SerializationRoundTrips()
- {
- var firstQuantity = new Information(1.2m, InformationUnit.Exabit);
- var secondQuantity = new Information(2, InformationUnit.Exabyte);
- var quantities = new List { firstQuantity, secondQuantity };
-
- var payload = SerializeObject(quantities);
- var results = DeserializeObject>(payload);
-
- Assert.Collection(results, result =>
- {
- Assert.Equal(firstQuantity.Unit, result.Unit);
- Assert.Equal(firstQuantity.Value, result.Value);
- Assert.Equal(firstQuantity, result);
- }, result =>
- {
- Assert.Equal(secondQuantity.Unit, result.Unit);
- Assert.Equal(secondQuantity.Value, result.Value);
- Assert.Equal(secondQuantity, result);
- });
- }
-
[Fact]
public virtual void TupleOfMixedValueQuantities_SerializationRoundTrips()
{
@@ -237,47 +176,6 @@ public void ClassOfDoubleAndNullUnits_SerializationRoundTrips()
Assert.Null(results.NullableQuantity);
}
- [Fact]
- public void ClassOfDecimalAndNullUnits_SerializationRoundTrips()
- {
- var quantity = new Information(2, InformationUnit.Exabyte);
- var quantities = new TestObject { Quantity = quantity, NullableQuantity = null };
-
- var payload = SerializeObject(quantities);
- var results = DeserializeObject>(payload);
-
- Assert.Equal(quantity.Unit, results.Quantity.Unit);
- Assert.Equal(quantity.Value, results.Quantity.Value);
- Assert.Equal(quantity, results.Quantity);
- Assert.Null(results.NullableQuantity);
- }
-
- [Fact]
- [SuppressMessage("ReSharper", "PossibleInvalidOperationException")]
- public void ClassOfMixedValueQuantities_SerializationRoundTrips()
- {
- var doubleQuantity = new Mass(1.2, MassUnit.Milligram);
- var decimalQuantity = new Information(2, InformationUnit.Exabyte);
- var quantities = new TestObject
- {
- Quantity = doubleQuantity, NullableQuantity = doubleQuantity, DecimalQuantity = decimalQuantity
- };
-
- var payload = SerializeObject(quantities);
- var results = DeserializeObject>(payload);
-
- Assert.Equal(doubleQuantity.Unit, results.Quantity.Unit);
- Assert.Equal(doubleQuantity.Value, results.Quantity.Value);
- Assert.Equal(doubleQuantity, results.Quantity);
- Assert.Equal(doubleQuantity.Unit, results.NullableQuantity!.Value.Unit);
- Assert.Equal(doubleQuantity.Value, results.NullableQuantity.Value.Value);
- Assert.Equal(doubleQuantity, results.NullableQuantity);
- Assert.Equal(decimalQuantity.Unit, results.DecimalQuantity.Unit);
- Assert.Equal(decimalQuantity.Value, results.DecimalQuantity.Value);
- Assert.Equal(decimalQuantity, results.DecimalQuantity);
- Assert.Null(results.NullableDecimalQuantity);
- }
-
[Fact]
public void ClassOfInterfaceQuantity_SerializationRoundTrips()
{
@@ -292,21 +190,6 @@ public void ClassOfInterfaceQuantity_SerializationRoundTrips()
Assert.Equal(quantity, result.Quantity);
}
- [Fact]
- public void ClassOfInterfaceDecimalValueQuantity_SerializationRoundTrips()
- {
- var quantity = new Information(2, InformationUnit.Exabyte);
- var quantityObject = new TestInterfaceObject { Quantity = quantity };
-
- var payload = SerializeObject(quantityObject);
- var result = DeserializeObject(payload);
-
- Assert.Equal(quantity.Unit, result.Quantity.Unit);
- Assert.Equal(quantity.Value, ((IValueQuantity)result.Quantity).Value);
- Assert.Equal(quantity, result.Quantity);
- Assert.Equal("2", ((IValueQuantity)result.Quantity).Value.ToString(CultureInfo.InvariantCulture));
- }
-
[DataContract]
protected class TestObject
where TQuantity : struct, IQuantity
@@ -317,17 +200,5 @@ protected class TestObject
[DataMember]
public TQuantity? NullableQuantity { get; set; }
}
-
- [DataContract]
- protected class TestObject : TestObject
- where TDoubleQuantity : struct, IQuantity
- where TDecimalQuantity : struct, IQuantity, IDecimalQuantity
- {
- [DataMember]
- public TDecimalQuantity DecimalQuantity { get; set; }
-
- [DataMember]
- public TDecimalQuantity? NullableDecimalQuantity { get; set; }
- }
}
}
diff --git a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs
index 9b82dad602..f37b32293c 100644
--- a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs
+++ b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs
@@ -47,24 +47,13 @@ public void DoubleQuantity_SerializedWithValueAndMemberName()
Assert.Equal(expectedXml, xml);
}
- [Fact]
- public void DecimalQuantity_SerializedWithValueAndMemberName()
- {
- var quantity = new Information(1.20m, InformationUnit.Exabyte);
- var expectedXml = $"1.20Exabyte";
-
- var xml = SerializeObject(quantity);
-
- Assert.Equal(expectedXml, xml);
- }
-
[Fact]
public void InterfaceObject_IncludesTypeInformation()
{
- var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) };
+ var testObject = new TestInterfaceObject { Quantity = new Information(1.20, InformationUnit.Exabyte) };
var quantityNamespace = "xmlns:a=\"http://schemas.datacontract.org/2004/07/UnitsNet\""; // there is an extra 'a' compared to Namespace
- var expectedQuantityXml = $"1.20Exabyte";
+ var expectedQuantityXml = $"1.2Exabyte";
var expectedXml = $"{expectedQuantityXml}";
var xml = SerializeObject(testObject);
diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
index a351855b9f..22ef4aa2fa 100644
--- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
@@ -40,8 +40,7 @@ namespace UnitsNet
///
[DataContract]
public readonly partial struct BitRate :
- IArithmeticQuantity,
- IDecimalQuantity,
+ IArithmeticQuantity,
IComparable,
IComparable,
IConvertible,
@@ -52,7 +51,7 @@ namespace UnitsNet
/// The numeric value this quantity was constructed with.
///
[DataMember(Name = "Value", Order = 1)]
- private readonly decimal _value;
+ private readonly double _value;
///
/// The unit this quantity was constructed with.
@@ -108,7 +107,7 @@ static BitRate()
/// The numeric value to construct this quantity with.
/// The unit representation to construct this quantity with.
/// If value is NaN or Infinity.
- public BitRate(decimal value, BitRateUnit unit)
+ public BitRate(double value, BitRateUnit unit)
{
_value = value;
_unit = unit;
@@ -122,7 +121,7 @@ public BitRate(decimal value, BitRateUnit unit)
/// The unit system to create the quantity with.
/// The given is null.
/// No unit was found for the given .
- public BitRate(decimal value, UnitSystem unitSystem)
+ public BitRate(double value, UnitSystem unitSystem)
{
if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
@@ -173,7 +172,7 @@ public BitRate(decimal value, UnitSystem unitSystem)
///
/// The numeric value this quantity was constructed with.
///
- public decimal Value => _value;
+ public double Value => _value;
///
QuantityValue IQuantity.Value => _value;
@@ -199,134 +198,134 @@ public BitRate(decimal value, UnitSystem unitSystem)
#region Conversion Properties
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal BitsPerSecond => As(BitRateUnit.BitPerSecond);
+ public double BitsPerSecond => As(BitRateUnit.BitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal BytesPerSecond => As(BitRateUnit.BytePerSecond);
+ public double BytesPerSecond => As(BitRateUnit.BytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond);
+ public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond);
+ public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond);
+ public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond);
+ public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond);
+ public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond);
+ public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond);
+ public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond);
+ public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond);
+ public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond);
+ public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond);
+ public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond);
+ public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond);
+ public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond);
+ public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond);
+ public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond);
+ public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond);
+ public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond);
+ public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond);
+ public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond);
+ public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond);
+ public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond);
+ public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond);
+ public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond);
+ public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond);
#endregion
@@ -427,7 +426,7 @@ public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider
/// If value is NaN or Infinity.
public static BitRate FromBitsPerSecond(QuantityValue bitspersecond)
{
- decimal value = (decimal) bitspersecond;
+ double value = (double) bitspersecond;
return new BitRate(value, BitRateUnit.BitPerSecond);
}
@@ -437,7 +436,7 @@ public static BitRate FromBitsPerSecond(QuantityValue bitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromBytesPerSecond(QuantityValue bytespersecond)
{
- decimal value = (decimal) bytespersecond;
+ double value = (double) bytespersecond;
return new BitRate(value, BitRateUnit.BytePerSecond);
}
@@ -447,7 +446,7 @@ public static BitRate FromBytesPerSecond(QuantityValue bytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond)
{
- decimal value = (decimal) exabitspersecond;
+ double value = (double) exabitspersecond;
return new BitRate(value, BitRateUnit.ExabitPerSecond);
}
@@ -457,7 +456,7 @@ public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond)
{
- decimal value = (decimal) exabytespersecond;
+ double value = (double) exabytespersecond;
return new BitRate(value, BitRateUnit.ExabytePerSecond);
}
@@ -467,7 +466,7 @@ public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond)
{
- decimal value = (decimal) exbibitspersecond;
+ double value = (double) exbibitspersecond;
return new BitRate(value, BitRateUnit.ExbibitPerSecond);
}
@@ -477,7 +476,7 @@ public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond)
{
- decimal value = (decimal) exbibytespersecond;
+ double value = (double) exbibytespersecond;
return new BitRate(value, BitRateUnit.ExbibytePerSecond);
}
@@ -487,7 +486,7 @@ public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond)
{
- decimal value = (decimal) gibibitspersecond;
+ double value = (double) gibibitspersecond;
return new BitRate(value, BitRateUnit.GibibitPerSecond);
}
@@ -497,7 +496,7 @@ public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond)
{
- decimal value = (decimal) gibibytespersecond;
+ double value = (double) gibibytespersecond;
return new BitRate(value, BitRateUnit.GibibytePerSecond);
}
@@ -507,7 +506,7 @@ public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond)
{
- decimal value = (decimal) gigabitspersecond;
+ double value = (double) gigabitspersecond;
return new BitRate(value, BitRateUnit.GigabitPerSecond);
}
@@ -517,7 +516,7 @@ public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond)
{
- decimal value = (decimal) gigabytespersecond;
+ double value = (double) gigabytespersecond;
return new BitRate(value, BitRateUnit.GigabytePerSecond);
}
@@ -527,7 +526,7 @@ public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond)
{
- decimal value = (decimal) kibibitspersecond;
+ double value = (double) kibibitspersecond;
return new BitRate(value, BitRateUnit.KibibitPerSecond);
}
@@ -537,7 +536,7 @@ public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond)
{
- decimal value = (decimal) kibibytespersecond;
+ double value = (double) kibibytespersecond;
return new BitRate(value, BitRateUnit.KibibytePerSecond);
}
@@ -547,7 +546,7 @@ public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond)
{
- decimal value = (decimal) kilobitspersecond;
+ double value = (double) kilobitspersecond;
return new BitRate(value, BitRateUnit.KilobitPerSecond);
}
@@ -557,7 +556,7 @@ public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond)
{
- decimal value = (decimal) kilobytespersecond;
+ double value = (double) kilobytespersecond;
return new BitRate(value, BitRateUnit.KilobytePerSecond);
}
@@ -567,7 +566,7 @@ public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond)
{
- decimal value = (decimal) mebibitspersecond;
+ double value = (double) mebibitspersecond;
return new BitRate(value, BitRateUnit.MebibitPerSecond);
}
@@ -577,7 +576,7 @@ public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond)
{
- decimal value = (decimal) mebibytespersecond;
+ double value = (double) mebibytespersecond;
return new BitRate(value, BitRateUnit.MebibytePerSecond);
}
@@ -587,7 +586,7 @@ public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond)
{
- decimal value = (decimal) megabitspersecond;
+ double value = (double) megabitspersecond;
return new BitRate(value, BitRateUnit.MegabitPerSecond);
}
@@ -597,7 +596,7 @@ public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond)
{
- decimal value = (decimal) megabytespersecond;
+ double value = (double) megabytespersecond;
return new BitRate(value, BitRateUnit.MegabytePerSecond);
}
@@ -607,7 +606,7 @@ public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond)
{
- decimal value = (decimal) pebibitspersecond;
+ double value = (double) pebibitspersecond;
return new BitRate(value, BitRateUnit.PebibitPerSecond);
}
@@ -617,7 +616,7 @@ public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond)
{
- decimal value = (decimal) pebibytespersecond;
+ double value = (double) pebibytespersecond;
return new BitRate(value, BitRateUnit.PebibytePerSecond);
}
@@ -627,7 +626,7 @@ public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond)
{
- decimal value = (decimal) petabitspersecond;
+ double value = (double) petabitspersecond;
return new BitRate(value, BitRateUnit.PetabitPerSecond);
}
@@ -637,7 +636,7 @@ public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond)
{
- decimal value = (decimal) petabytespersecond;
+ double value = (double) petabytespersecond;
return new BitRate(value, BitRateUnit.PetabytePerSecond);
}
@@ -647,7 +646,7 @@ public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond)
{
- decimal value = (decimal) tebibitspersecond;
+ double value = (double) tebibitspersecond;
return new BitRate(value, BitRateUnit.TebibitPerSecond);
}
@@ -657,7 +656,7 @@ public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond)
{
- decimal value = (decimal) tebibytespersecond;
+ double value = (double) tebibytespersecond;
return new BitRate(value, BitRateUnit.TebibytePerSecond);
}
@@ -667,7 +666,7 @@ public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond)
/// If value is NaN or Infinity.
public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond)
{
- decimal value = (decimal) terabitspersecond;
+ double value = (double) terabitspersecond;
return new BitRate(value, BitRateUnit.TerabitPerSecond);
}
@@ -677,7 +676,7 @@ public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond)
/// If value is NaN or Infinity.
public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond)
{
- decimal value = (decimal) terabytespersecond;
+ double value = (double) terabytespersecond;
return new BitRate(value, BitRateUnit.TerabytePerSecond);
}
@@ -689,7 +688,7 @@ public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond)
/// BitRate unit value.
public static BitRate From(QuantityValue value, BitRateUnit fromUnit)
{
- return new BitRate((decimal)value, fromUnit);
+ return new BitRate((double)value, fromUnit);
}
#endregion
@@ -859,25 +858,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa
}
/// Get from multiplying value and .
- public static BitRate operator *(decimal left, BitRate right)
+ public static BitRate operator *(double left, BitRate right)
{
return new BitRate(left * right.Value, right.Unit);
}
/// Get from multiplying value and .
- public static BitRate operator *(BitRate left, decimal right)
+ public static BitRate operator *(BitRate left, double right)
{
return new BitRate(left.Value * right, left.Unit);
}
/// Get from dividing by value.
- public static BitRate operator /(BitRate left, decimal right)
+ public static BitRate operator /(BitRate left, double right)
{
return new BitRate(left.Value / right, left.Unit);
}
/// Get ratio value from dividing by .
- public static decimal operator /(BitRate left, BitRate right)
+ public static double operator /(BitRate left, BitRate right)
{
return left.BitsPerSecond / right.BitsPerSecond;
}
@@ -1018,7 +1017,7 @@ public int CompareTo(BitRate other)
///
///
/// Note that it is advised against specifying zero difference, due to the nature
- /// of floating-point operations and using decimal internally.
+ /// of floating-point operations and using double internally.
///
///
/// The other quantity to compare to.
@@ -1026,7 +1025,7 @@ public int CompareTo(BitRate other)
/// The comparison type: either relative or absolute.
/// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
[Obsolete("Use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")]
- public bool Equals(BitRate other, decimal tolerance, ComparisonType comparisonType)
+ public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType)
{
if (tolerance < 0)
throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0.");
@@ -1075,7 +1074,7 @@ public override int GetHashCode()
/// Convert to the unit representation .
///
/// Value converted to the specified unit.
- public decimal As(BitRateUnit unit)
+ public double As(BitRateUnit unit)
{
if (Unit == unit)
return Value;
@@ -1083,13 +1082,8 @@ public decimal As(BitRateUnit unit)
return ToUnit(unit).Value;
}
- double IQuantity.As(BitRateUnit unit)
- {
- return (double)As(unit);
- }
-
///
- public decimal As(UnitSystem unitSystem)
+ public double As(UnitSystem unitSystem)
{
if (unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
@@ -1103,12 +1097,6 @@ public decimal As(UnitSystem unitSystem)
return As(firstUnitInfo.Value);
}
- ///
- double IQuantity.As(UnitSystem unitSystem)
- {
- return (double)As(unitSystem);
- }
-
///
double IQuantity.As(Enum unit)
{
@@ -1119,7 +1107,7 @@ double IQuantity.As(Enum unit)
}
///
- decimal IValueQuantity.As(Enum unit)
+ double IValueQuantity.As(Enum unit)
{
if (!(unit is BitRateUnit typedUnit))
throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit));
@@ -1185,58 +1173,58 @@ private bool TryToUnit(BitRateUnit unit, [NotNullWhen(true)] out BitRate? conver
BitRate? convertedOrNull = (Unit, unit) switch
{
// BitRateUnit -> BaseUnit
- (BitRateUnit.BytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8m, BitRateUnit.BitPerSecond),
- (BitRateUnit.ExabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e18m, BitRateUnit.BitPerSecond),
- (BitRateUnit.ExabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1e18m, BitRateUnit.BitPerSecond),
- (BitRateUnit.ExbibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.ExbibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.GibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024m * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.GibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * (1024m * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.GigabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e9m, BitRateUnit.BitPerSecond),
- (BitRateUnit.GigabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1e9m, BitRateUnit.BitPerSecond),
- (BitRateUnit.KibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1024m, BitRateUnit.BitPerSecond),
- (BitRateUnit.KibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1024m, BitRateUnit.BitPerSecond),
- (BitRateUnit.KilobitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e3m, BitRateUnit.BitPerSecond),
- (BitRateUnit.KilobytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1e3m, BitRateUnit.BitPerSecond),
- (BitRateUnit.MebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024m * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.MebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * (1024m * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.MegabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e6m, BitRateUnit.BitPerSecond),
- (BitRateUnit.MegabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1e6m, BitRateUnit.BitPerSecond),
- (BitRateUnit.PebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024m * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.PebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * (1024m * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.PetabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e15m, BitRateUnit.BitPerSecond),
- (BitRateUnit.PetabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1e15m, BitRateUnit.BitPerSecond),
- (BitRateUnit.TebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024m * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.TebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * (1024m * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
- (BitRateUnit.TerabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e12m, BitRateUnit.BitPerSecond),
- (BitRateUnit.TerabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8m) * 1e12m, BitRateUnit.BitPerSecond),
+ (BitRateUnit.BytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8, BitRateUnit.BitPerSecond),
+ (BitRateUnit.ExabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e18d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.ExabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e18d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.ExbibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.ExbibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.GibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.GibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.GigabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e9d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.GigabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e9d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.KibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1024d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.KibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1024d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.KilobitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e3d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.KilobytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e3d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.MebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.MebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.MegabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e6d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.MegabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e6d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.PebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.PebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.PetabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e15d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.PetabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e15d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.TebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.TebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond),
+ (BitRateUnit.TerabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e12d, BitRateUnit.BitPerSecond),
+ (BitRateUnit.TerabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e12d, BitRateUnit.BitPerSecond),
// BaseUnit -> BitRateUnit
- (BitRateUnit.BitPerSecond, BitRateUnit.BytePerSecond) => new BitRate(_value / 8m, BitRateUnit.BytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.ExabitPerSecond) => new BitRate((_value) / 1e18m, BitRateUnit.ExabitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.ExabytePerSecond) => new BitRate((_value / 8m) / 1e18m, BitRateUnit.ExabytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.ExbibitPerSecond) => new BitRate((_value) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.ExbibitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.ExbibytePerSecond) => new BitRate((_value / 8m) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.ExbibytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.GibibitPerSecond) => new BitRate((_value) / (1024m * 1024 * 1024), BitRateUnit.GibibitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.GibibytePerSecond) => new BitRate((_value / 8m) / (1024m * 1024 * 1024), BitRateUnit.GibibytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.GigabitPerSecond) => new BitRate((_value) / 1e9m, BitRateUnit.GigabitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.GigabytePerSecond) => new BitRate((_value / 8m) / 1e9m, BitRateUnit.GigabytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.KibibitPerSecond) => new BitRate((_value) / 1024m, BitRateUnit.KibibitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.KibibytePerSecond) => new BitRate((_value / 8m) / 1024m, BitRateUnit.KibibytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.KilobitPerSecond) => new BitRate((_value) / 1e3m, BitRateUnit.KilobitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.KilobytePerSecond) => new BitRate((_value / 8m) / 1e3m, BitRateUnit.KilobytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.MebibitPerSecond) => new BitRate((_value) / (1024m * 1024), BitRateUnit.MebibitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.MebibytePerSecond) => new BitRate((_value / 8m) / (1024m * 1024), BitRateUnit.MebibytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.MegabitPerSecond) => new BitRate((_value) / 1e6m, BitRateUnit.MegabitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.MegabytePerSecond) => new BitRate((_value / 8m) / 1e6m, BitRateUnit.MegabytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.PebibitPerSecond) => new BitRate((_value) / (1024m * 1024 * 1024 * 1024 * 1024), BitRateUnit.PebibitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.PebibytePerSecond) => new BitRate((_value / 8m) / (1024m * 1024 * 1024 * 1024 * 1024), BitRateUnit.PebibytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.PetabitPerSecond) => new BitRate((_value) / 1e15m, BitRateUnit.PetabitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.PetabytePerSecond) => new BitRate((_value / 8m) / 1e15m, BitRateUnit.PetabytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.TebibitPerSecond) => new BitRate((_value) / (1024m * 1024 * 1024 * 1024), BitRateUnit.TebibitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.TebibytePerSecond) => new BitRate((_value / 8m) / (1024m * 1024 * 1024 * 1024), BitRateUnit.TebibytePerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.TerabitPerSecond) => new BitRate((_value) / 1e12m, BitRateUnit.TerabitPerSecond),
- (BitRateUnit.BitPerSecond, BitRateUnit.TerabytePerSecond) => new BitRate((_value / 8m) / 1e12m, BitRateUnit.TerabytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.BytePerSecond) => new BitRate(_value / 8, BitRateUnit.BytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.ExabitPerSecond) => new BitRate((_value) / 1e18d, BitRateUnit.ExabitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.ExabytePerSecond) => new BitRate((_value / 8) / 1e18d, BitRateUnit.ExabytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.ExbibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.ExbibitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.ExbibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.ExbibytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.GibibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024), BitRateUnit.GibibitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.GibibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024), BitRateUnit.GibibytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.GigabitPerSecond) => new BitRate((_value) / 1e9d, BitRateUnit.GigabitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.GigabytePerSecond) => new BitRate((_value / 8) / 1e9d, BitRateUnit.GigabytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.KibibitPerSecond) => new BitRate((_value) / 1024d, BitRateUnit.KibibitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.KibibytePerSecond) => new BitRate((_value / 8) / 1024d, BitRateUnit.KibibytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.KilobitPerSecond) => new BitRate((_value) / 1e3d, BitRateUnit.KilobitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.KilobytePerSecond) => new BitRate((_value / 8) / 1e3d, BitRateUnit.KilobytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.MebibitPerSecond) => new BitRate((_value) / (1024d * 1024), BitRateUnit.MebibitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.MebibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024), BitRateUnit.MebibytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.MegabitPerSecond) => new BitRate((_value) / 1e6d, BitRateUnit.MegabitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.MegabytePerSecond) => new BitRate((_value / 8) / 1e6d, BitRateUnit.MegabytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.PebibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.PebibitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.PebibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.PebibytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.PetabitPerSecond) => new BitRate((_value) / 1e15d, BitRateUnit.PetabitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.PetabytePerSecond) => new BitRate((_value / 8) / 1e15d, BitRateUnit.PetabytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.TebibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024 * 1024), BitRateUnit.TebibitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.TebibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024 * 1024), BitRateUnit.TebibytePerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.TerabitPerSecond) => new BitRate((_value) / 1e12d, BitRateUnit.TerabitPerSecond),
+ (BitRateUnit.BitPerSecond, BitRateUnit.TerabytePerSecond) => new BitRate((_value / 8) / 1e12d, BitRateUnit.TerabytePerSecond),
_ => null
};
@@ -1285,7 +1273,7 @@ public BitRate ToUnit(UnitSystem unitSystem)
IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
///
- IValueQuantity IValueQuantity.ToUnit(Enum unit)
+ IValueQuantity IValueQuantity.ToUnit(Enum unit)
{
if (unit is not BitRateUnit typedUnit)
throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit));
@@ -1294,7 +1282,7 @@ IValueQuantity IValueQuantity.ToUnit(Enum unit)
}
///
- IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
+ IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs
index f9a6009a23..36dcc10bf3 100644
--- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs
@@ -37,8 +37,7 @@ namespace UnitsNet
///
[DataContract]
public readonly partial struct Information :
- IArithmeticQuantity,
- IDecimalQuantity,
+ IArithmeticQuantity,
IComparable,
IComparable,
IConvertible,
@@ -49,7 +48,7 @@ namespace UnitsNet
/// The numeric value this quantity was constructed with.
///
[DataMember(Name = "Value", Order = 1)]
- private readonly decimal _value;
+ private readonly double _value;
///
/// The unit this quantity was constructed with.
@@ -105,7 +104,7 @@ static Information()
/// The numeric value to construct this quantity with.
/// The unit representation to construct this quantity with.
/// If value is NaN or Infinity.
- public Information(decimal value, InformationUnit unit)
+ public Information(double value, InformationUnit unit)
{
_value = value;
_unit = unit;
@@ -119,7 +118,7 @@ public Information(decimal value, InformationUnit unit)
/// The unit system to create the quantity with.
/// The given is null.
/// No unit was found for the given .
- public Information(decimal value, UnitSystem unitSystem)
+ public Information(double value, UnitSystem unitSystem)
{
if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
@@ -170,7 +169,7 @@ public Information(decimal value, UnitSystem unitSystem)
///
/// The numeric value this quantity was constructed with.
///
- public decimal Value => _value;
+ public double Value => _value;
///
QuantityValue IQuantity.Value => _value;
@@ -196,134 +195,134 @@ public Information(decimal value, UnitSystem unitSystem)
#region Conversion Properties
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Bits => As(InformationUnit.Bit);
+ public double Bits => As(InformationUnit.Bit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Bytes => As(InformationUnit.Byte);
+ public double Bytes => As(InformationUnit.Byte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Exabits => As(InformationUnit.Exabit);
+ public double Exabits => As(InformationUnit.Exabit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Exabytes => As(InformationUnit.Exabyte);
+ public double Exabytes => As(InformationUnit.Exabyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Exbibits => As(InformationUnit.Exbibit);
+ public double Exbibits => As(InformationUnit.Exbibit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Exbibytes => As(InformationUnit.Exbibyte);
+ public double Exbibytes => As(InformationUnit.Exbibyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Gibibits => As(InformationUnit.Gibibit);
+ public double Gibibits => As(InformationUnit.Gibibit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Gibibytes => As(InformationUnit.Gibibyte);
+ public double Gibibytes => As(InformationUnit.Gibibyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Gigabits => As(InformationUnit.Gigabit);
+ public double Gigabits => As(InformationUnit.Gigabit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Gigabytes => As(InformationUnit.Gigabyte);
+ public double Gigabytes => As(InformationUnit.Gigabyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Kibibits => As(InformationUnit.Kibibit);
+ public double Kibibits => As(InformationUnit.Kibibit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Kibibytes => As(InformationUnit.Kibibyte);
+ public double Kibibytes => As(InformationUnit.Kibibyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Kilobits => As(InformationUnit.Kilobit);
+ public double Kilobits => As(InformationUnit.Kilobit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Kilobytes => As(InformationUnit.Kilobyte);
+ public double Kilobytes => As(InformationUnit.Kilobyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Mebibits => As(InformationUnit.Mebibit);
+ public double Mebibits => As(InformationUnit.Mebibit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Mebibytes => As(InformationUnit.Mebibyte);
+ public double Mebibytes => As(InformationUnit.Mebibyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Megabits => As(InformationUnit.Megabit);
+ public double Megabits => As(InformationUnit.Megabit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Megabytes => As(InformationUnit.Megabyte);
+ public double Megabytes => As(InformationUnit.Megabyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Pebibits => As(InformationUnit.Pebibit);
+ public double Pebibits => As(InformationUnit.Pebibit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Pebibytes => As(InformationUnit.Pebibyte);
+ public double Pebibytes => As(InformationUnit.Pebibyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Petabits => As(InformationUnit.Petabit);
+ public double Petabits => As(InformationUnit.Petabit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Petabytes => As(InformationUnit.Petabyte);
+ public double Petabytes => As(InformationUnit.Petabyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Tebibits => As(InformationUnit.Tebibit);
+ public double Tebibits => As(InformationUnit.Tebibit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Tebibytes => As(InformationUnit.Tebibyte);
+ public double Tebibytes => As(InformationUnit.Tebibyte);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Terabits => As(InformationUnit.Terabit);
+ public double Terabits => As(InformationUnit.Terabit);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Terabytes => As(InformationUnit.Terabyte);
+ public double Terabytes => As(InformationUnit.Terabyte);
#endregion
@@ -424,7 +423,7 @@ public static string GetAbbreviation(InformationUnit unit, IFormatProvider? prov
/// If value is NaN or Infinity.
public static Information FromBits(QuantityValue bits)
{
- decimal value = (decimal) bits;
+ double value = (double) bits;
return new Information(value, InformationUnit.Bit);
}
@@ -434,7 +433,7 @@ public static Information FromBits(QuantityValue bits)
/// If value is NaN or Infinity.
public static Information FromBytes(QuantityValue bytes)
{
- decimal value = (decimal) bytes;
+ double value = (double) bytes;
return new Information(value, InformationUnit.Byte);
}
@@ -444,7 +443,7 @@ public static Information FromBytes(QuantityValue bytes)
/// If value is NaN or Infinity.
public static Information FromExabits(QuantityValue exabits)
{
- decimal value = (decimal) exabits;
+ double value = (double) exabits;
return new Information(value, InformationUnit.Exabit);
}
@@ -454,7 +453,7 @@ public static Information FromExabits(QuantityValue exabits)
/// If value is NaN or Infinity.
public static Information FromExabytes(QuantityValue exabytes)
{
- decimal value = (decimal) exabytes;
+ double value = (double) exabytes;
return new Information(value, InformationUnit.Exabyte);
}
@@ -464,7 +463,7 @@ public static Information FromExabytes(QuantityValue exabytes)
/// If value is NaN or Infinity.
public static Information FromExbibits(QuantityValue exbibits)
{
- decimal value = (decimal) exbibits;
+ double value = (double) exbibits;
return new Information(value, InformationUnit.Exbibit);
}
@@ -474,7 +473,7 @@ public static Information FromExbibits(QuantityValue exbibits)
/// If value is NaN or Infinity.
public static Information FromExbibytes(QuantityValue exbibytes)
{
- decimal value = (decimal) exbibytes;
+ double value = (double) exbibytes;
return new Information(value, InformationUnit.Exbibyte);
}
@@ -484,7 +483,7 @@ public static Information FromExbibytes(QuantityValue exbibytes)
/// If value is NaN or Infinity.
public static Information FromGibibits(QuantityValue gibibits)
{
- decimal value = (decimal) gibibits;
+ double value = (double) gibibits;
return new Information(value, InformationUnit.Gibibit);
}
@@ -494,7 +493,7 @@ public static Information FromGibibits(QuantityValue gibibits)
/// If value is NaN or Infinity.
public static Information FromGibibytes(QuantityValue gibibytes)
{
- decimal value = (decimal) gibibytes;
+ double value = (double) gibibytes;
return new Information(value, InformationUnit.Gibibyte);
}
@@ -504,7 +503,7 @@ public static Information FromGibibytes(QuantityValue gibibytes)
/// If value is NaN or Infinity.
public static Information FromGigabits(QuantityValue gigabits)
{
- decimal value = (decimal) gigabits;
+ double value = (double) gigabits;
return new Information(value, InformationUnit.Gigabit);
}
@@ -514,7 +513,7 @@ public static Information FromGigabits(QuantityValue gigabits)
/// If value is NaN or Infinity.
public static Information FromGigabytes(QuantityValue gigabytes)
{
- decimal value = (decimal) gigabytes;
+ double value = (double) gigabytes;
return new Information(value, InformationUnit.Gigabyte);
}
@@ -524,7 +523,7 @@ public static Information FromGigabytes(QuantityValue gigabytes)
/// If value is NaN or Infinity.
public static Information FromKibibits(QuantityValue kibibits)
{
- decimal value = (decimal) kibibits;
+ double value = (double) kibibits;
return new Information(value, InformationUnit.Kibibit);
}
@@ -534,7 +533,7 @@ public static Information FromKibibits(QuantityValue kibibits)
/// If value is NaN or Infinity.
public static Information FromKibibytes(QuantityValue kibibytes)
{
- decimal value = (decimal) kibibytes;
+ double value = (double) kibibytes;
return new Information(value, InformationUnit.Kibibyte);
}
@@ -544,7 +543,7 @@ public static Information FromKibibytes(QuantityValue kibibytes)
/// If value is NaN or Infinity.
public static Information FromKilobits(QuantityValue kilobits)
{
- decimal value = (decimal) kilobits;
+ double value = (double) kilobits;
return new Information(value, InformationUnit.Kilobit);
}
@@ -554,7 +553,7 @@ public static Information FromKilobits(QuantityValue kilobits)
/// If value is NaN or Infinity.
public static Information FromKilobytes(QuantityValue kilobytes)
{
- decimal value = (decimal) kilobytes;
+ double value = (double) kilobytes;
return new Information(value, InformationUnit.Kilobyte);
}
@@ -564,7 +563,7 @@ public static Information FromKilobytes(QuantityValue kilobytes)
/// If value is NaN or Infinity.
public static Information FromMebibits(QuantityValue mebibits)
{
- decimal value = (decimal) mebibits;
+ double value = (double) mebibits;
return new Information(value, InformationUnit.Mebibit);
}
@@ -574,7 +573,7 @@ public static Information FromMebibits(QuantityValue mebibits)
/// If value is NaN or Infinity.
public static Information FromMebibytes(QuantityValue mebibytes)
{
- decimal value = (decimal) mebibytes;
+ double value = (double) mebibytes;
return new Information(value, InformationUnit.Mebibyte);
}
@@ -584,7 +583,7 @@ public static Information FromMebibytes(QuantityValue mebibytes)
/// If value is NaN or Infinity.
public static Information FromMegabits(QuantityValue megabits)
{
- decimal value = (decimal) megabits;
+ double value = (double) megabits;
return new Information(value, InformationUnit.Megabit);
}
@@ -594,7 +593,7 @@ public static Information FromMegabits(QuantityValue megabits)
/// If value is NaN or Infinity.
public static Information FromMegabytes(QuantityValue megabytes)
{
- decimal value = (decimal) megabytes;
+ double value = (double) megabytes;
return new Information(value, InformationUnit.Megabyte);
}
@@ -604,7 +603,7 @@ public static Information FromMegabytes(QuantityValue megabytes)
/// If value is NaN or Infinity.
public static Information FromPebibits(QuantityValue pebibits)
{
- decimal value = (decimal) pebibits;
+ double value = (double) pebibits;
return new Information(value, InformationUnit.Pebibit);
}
@@ -614,7 +613,7 @@ public static Information FromPebibits(QuantityValue pebibits)
/// If value is NaN or Infinity.
public static Information FromPebibytes(QuantityValue pebibytes)
{
- decimal value = (decimal) pebibytes;
+ double value = (double) pebibytes;
return new Information(value, InformationUnit.Pebibyte);
}
@@ -624,7 +623,7 @@ public static Information FromPebibytes(QuantityValue pebibytes)
/// If value is NaN or Infinity.
public static Information FromPetabits(QuantityValue petabits)
{
- decimal value = (decimal) petabits;
+ double value = (double) petabits;
return new Information(value, InformationUnit.Petabit);
}
@@ -634,7 +633,7 @@ public static Information FromPetabits(QuantityValue petabits)
/// If value is NaN or Infinity.
public static Information FromPetabytes(QuantityValue petabytes)
{
- decimal value = (decimal) petabytes;
+ double value = (double) petabytes;
return new Information(value, InformationUnit.Petabyte);
}
@@ -644,7 +643,7 @@ public static Information FromPetabytes(QuantityValue petabytes)
/// If value is NaN or Infinity.
public static Information FromTebibits(QuantityValue tebibits)
{
- decimal value = (decimal) tebibits;
+ double value = (double) tebibits;
return new Information(value, InformationUnit.Tebibit);
}
@@ -654,7 +653,7 @@ public static Information FromTebibits(QuantityValue tebibits)
/// If value is NaN or Infinity.
public static Information FromTebibytes(QuantityValue tebibytes)
{
- decimal value = (decimal) tebibytes;
+ double value = (double) tebibytes;
return new Information(value, InformationUnit.Tebibyte);
}
@@ -664,7 +663,7 @@ public static Information FromTebibytes(QuantityValue tebibytes)
/// If value is NaN or Infinity.
public static Information FromTerabits(QuantityValue terabits)
{
- decimal value = (decimal) terabits;
+ double value = (double) terabits;
return new Information(value, InformationUnit.Terabit);
}
@@ -674,7 +673,7 @@ public static Information FromTerabits(QuantityValue terabits)
/// If value is NaN or Infinity.
public static Information FromTerabytes(QuantityValue terabytes)
{
- decimal value = (decimal) terabytes;
+ double value = (double) terabytes;
return new Information(value, InformationUnit.Terabyte);
}
@@ -686,7 +685,7 @@ public static Information FromTerabytes(QuantityValue terabytes)
/// Information unit value.
public static Information From(QuantityValue value, InformationUnit fromUnit)
{
- return new Information((decimal)value, fromUnit);
+ return new Information((double)value, fromUnit);
}
#endregion
@@ -856,25 +855,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor
}
/// Get from multiplying value and .
- public static Information operator *(decimal left, Information right)
+ public static Information operator *(double left, Information right)
{
return new Information(left * right.Value, right.Unit);
}
/// Get from multiplying value and .
- public static Information operator *(Information left, decimal right)
+ public static Information operator *(Information left, double right)
{
return new Information(left.Value * right, left.Unit);
}
/// Get from dividing by value.
- public static Information operator /(Information left, decimal right)
+ public static Information operator /(Information left, double right)
{
return new Information(left.Value / right, left.Unit);
}
/// Get ratio value from dividing by .
- public static decimal operator /(Information left, Information right)
+ public static double operator /(Information left, Information right)
{
return left.Bits / right.Bits;
}
@@ -1015,7 +1014,7 @@ public int CompareTo(Information other)
///
///
/// Note that it is advised against specifying zero difference, due to the nature
- /// of floating-point operations and using decimal internally.
+ /// of floating-point operations and using double internally.
///
///
/// The other quantity to compare to.
@@ -1023,7 +1022,7 @@ public int CompareTo(Information other)
/// The comparison type: either relative or absolute.
/// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
[Obsolete("Use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")]
- public bool Equals(Information other, decimal tolerance, ComparisonType comparisonType)
+ public bool Equals(Information other, double tolerance, ComparisonType comparisonType)
{
if (tolerance < 0)
throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0.");
@@ -1072,7 +1071,7 @@ public override int GetHashCode()
/// Convert to the unit representation .
///
/// Value converted to the specified unit.
- public decimal As(InformationUnit unit)
+ public double As(InformationUnit unit)
{
if (Unit == unit)
return Value;
@@ -1080,13 +1079,8 @@ public decimal As(InformationUnit unit)
return ToUnit(unit).Value;
}
- double IQuantity.As(InformationUnit unit)
- {
- return (double)As(unit);
- }
-
///
- public decimal As(UnitSystem unitSystem)
+ public double As(UnitSystem unitSystem)
{
if (unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
@@ -1100,12 +1094,6 @@ public decimal As(UnitSystem unitSystem)
return As(firstUnitInfo.Value);
}
- ///
- double IQuantity.As(UnitSystem unitSystem)
- {
- return (double)As(unitSystem);
- }
-
///
double IQuantity.As(Enum unit)
{
@@ -1116,7 +1104,7 @@ double IQuantity.As(Enum unit)
}
///
- decimal IValueQuantity.As(Enum unit)
+ double IValueQuantity.As(Enum unit)
{
if (!(unit is InformationUnit typedUnit))
throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit));
@@ -1182,58 +1170,58 @@ private bool TryToUnit(InformationUnit unit, [NotNullWhen(true)] out Information
Information? convertedOrNull = (Unit, unit) switch
{
// InformationUnit -> BaseUnit
- (InformationUnit.Byte, InformationUnit.Bit) => new Information(_value * 8m, InformationUnit.Bit),
- (InformationUnit.Exabit, InformationUnit.Bit) => new Information((_value) * 1e18m, InformationUnit.Bit),
- (InformationUnit.Exabyte, InformationUnit.Bit) => new Information((_value * 8m) * 1e18m, InformationUnit.Bit),
- (InformationUnit.Exbibit, InformationUnit.Bit) => new Information((_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Exbibyte, InformationUnit.Bit) => new Information((_value * 8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Gibibit, InformationUnit.Bit) => new Information((_value) * (1024m * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Gibibyte, InformationUnit.Bit) => new Information((_value * 8m) * (1024m * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Gigabit, InformationUnit.Bit) => new Information((_value) * 1e9m, InformationUnit.Bit),
- (InformationUnit.Gigabyte, InformationUnit.Bit) => new Information((_value * 8m) * 1e9m, InformationUnit.Bit),
- (InformationUnit.Kibibit, InformationUnit.Bit) => new Information((_value) * 1024m, InformationUnit.Bit),
- (InformationUnit.Kibibyte, InformationUnit.Bit) => new Information((_value * 8m) * 1024m, InformationUnit.Bit),
- (InformationUnit.Kilobit, InformationUnit.Bit) => new Information((_value) * 1e3m, InformationUnit.Bit),
- (InformationUnit.Kilobyte, InformationUnit.Bit) => new Information((_value * 8m) * 1e3m, InformationUnit.Bit),
- (InformationUnit.Mebibit, InformationUnit.Bit) => new Information((_value) * (1024m * 1024), InformationUnit.Bit),
- (InformationUnit.Mebibyte, InformationUnit.Bit) => new Information((_value * 8m) * (1024m * 1024), InformationUnit.Bit),
- (InformationUnit.Megabit, InformationUnit.Bit) => new Information((_value) * 1e6m, InformationUnit.Bit),
- (InformationUnit.Megabyte, InformationUnit.Bit) => new Information((_value * 8m) * 1e6m, InformationUnit.Bit),
- (InformationUnit.Pebibit, InformationUnit.Bit) => new Information((_value) * (1024m * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Pebibyte, InformationUnit.Bit) => new Information((_value * 8m) * (1024m * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Petabit, InformationUnit.Bit) => new Information((_value) * 1e15m, InformationUnit.Bit),
- (InformationUnit.Petabyte, InformationUnit.Bit) => new Information((_value * 8m) * 1e15m, InformationUnit.Bit),
- (InformationUnit.Tebibit, InformationUnit.Bit) => new Information((_value) * (1024m * 1024 * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Tebibyte, InformationUnit.Bit) => new Information((_value * 8m) * (1024m * 1024 * 1024 * 1024), InformationUnit.Bit),
- (InformationUnit.Terabit, InformationUnit.Bit) => new Information((_value) * 1e12m, InformationUnit.Bit),
- (InformationUnit.Terabyte, InformationUnit.Bit) => new Information((_value * 8m) * 1e12m, InformationUnit.Bit),
+ (InformationUnit.Byte, InformationUnit.Bit) => new Information(_value * 8, InformationUnit.Bit),
+ (InformationUnit.Exabit, InformationUnit.Bit) => new Information((_value) * 1e18d, InformationUnit.Bit),
+ (InformationUnit.Exabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e18d, InformationUnit.Bit),
+ (InformationUnit.Exbibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Exbibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Gibibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Gibibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Gigabit, InformationUnit.Bit) => new Information((_value) * 1e9d, InformationUnit.Bit),
+ (InformationUnit.Gigabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e9d, InformationUnit.Bit),
+ (InformationUnit.Kibibit, InformationUnit.Bit) => new Information((_value) * 1024d, InformationUnit.Bit),
+ (InformationUnit.Kibibyte, InformationUnit.Bit) => new Information((_value * 8) * 1024d, InformationUnit.Bit),
+ (InformationUnit.Kilobit, InformationUnit.Bit) => new Information((_value) * 1e3d, InformationUnit.Bit),
+ (InformationUnit.Kilobyte, InformationUnit.Bit) => new Information((_value * 8) * 1e3d, InformationUnit.Bit),
+ (InformationUnit.Mebibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024), InformationUnit.Bit),
+ (InformationUnit.Mebibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024), InformationUnit.Bit),
+ (InformationUnit.Megabit, InformationUnit.Bit) => new Information((_value) * 1e6d, InformationUnit.Bit),
+ (InformationUnit.Megabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e6d, InformationUnit.Bit),
+ (InformationUnit.Pebibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Pebibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Petabit, InformationUnit.Bit) => new Information((_value) * 1e15d, InformationUnit.Bit),
+ (InformationUnit.Petabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e15d, InformationUnit.Bit),
+ (InformationUnit.Tebibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Tebibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024 * 1024), InformationUnit.Bit),
+ (InformationUnit.Terabit, InformationUnit.Bit) => new Information((_value) * 1e12d, InformationUnit.Bit),
+ (InformationUnit.Terabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e12d, InformationUnit.Bit),
// BaseUnit -> InformationUnit
- (InformationUnit.Bit, InformationUnit.Byte) => new Information(_value / 8m, InformationUnit.Byte),
- (InformationUnit.Bit, InformationUnit.Exabit) => new Information((_value) / 1e18m, InformationUnit.Exabit),
- (InformationUnit.Bit, InformationUnit.Exabyte) => new Information((_value / 8m) / 1e18m, InformationUnit.Exabyte),
- (InformationUnit.Bit, InformationUnit.Exbibit) => new Information((_value) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Exbibit),
- (InformationUnit.Bit, InformationUnit.Exbibyte) => new Information((_value / 8m) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Exbibyte),
- (InformationUnit.Bit, InformationUnit.Gibibit) => new Information((_value) / (1024m * 1024 * 1024), InformationUnit.Gibibit),
- (InformationUnit.Bit, InformationUnit.Gibibyte) => new Information((_value / 8m) / (1024m * 1024 * 1024), InformationUnit.Gibibyte),
- (InformationUnit.Bit, InformationUnit.Gigabit) => new Information((_value) / 1e9m, InformationUnit.Gigabit),
- (InformationUnit.Bit, InformationUnit.Gigabyte) => new Information((_value / 8m) / 1e9m, InformationUnit.Gigabyte),
- (InformationUnit.Bit, InformationUnit.Kibibit) => new Information((_value) / 1024m, InformationUnit.Kibibit),
- (InformationUnit.Bit, InformationUnit.Kibibyte) => new Information((_value / 8m) / 1024m, InformationUnit.Kibibyte),
- (InformationUnit.Bit, InformationUnit.Kilobit) => new Information((_value) / 1e3m, InformationUnit.Kilobit),
- (InformationUnit.Bit, InformationUnit.Kilobyte) => new Information((_value / 8m) / 1e3m, InformationUnit.Kilobyte),
- (InformationUnit.Bit, InformationUnit.Mebibit) => new Information((_value) / (1024m * 1024), InformationUnit.Mebibit),
- (InformationUnit.Bit, InformationUnit.Mebibyte) => new Information((_value / 8m) / (1024m * 1024), InformationUnit.Mebibyte),
- (InformationUnit.Bit, InformationUnit.Megabit) => new Information((_value) / 1e6m, InformationUnit.Megabit),
- (InformationUnit.Bit, InformationUnit.Megabyte) => new Information((_value / 8m) / 1e6m, InformationUnit.Megabyte),
- (InformationUnit.Bit, InformationUnit.Pebibit) => new Information((_value) / (1024m * 1024 * 1024 * 1024 * 1024), InformationUnit.Pebibit),
- (InformationUnit.Bit, InformationUnit.Pebibyte) => new Information((_value / 8m) / (1024m * 1024 * 1024 * 1024 * 1024), InformationUnit.Pebibyte),
- (InformationUnit.Bit, InformationUnit.Petabit) => new Information((_value) / 1e15m, InformationUnit.Petabit),
- (InformationUnit.Bit, InformationUnit.Petabyte) => new Information((_value / 8m) / 1e15m, InformationUnit.Petabyte),
- (InformationUnit.Bit, InformationUnit.Tebibit) => new Information((_value) / (1024m * 1024 * 1024 * 1024), InformationUnit.Tebibit),
- (InformationUnit.Bit, InformationUnit.Tebibyte) => new Information((_value / 8m) / (1024m * 1024 * 1024 * 1024), InformationUnit.Tebibyte),
- (InformationUnit.Bit, InformationUnit.Terabit) => new Information((_value) / 1e12m, InformationUnit.Terabit),
- (InformationUnit.Bit, InformationUnit.Terabyte) => new Information((_value / 8m) / 1e12m, InformationUnit.Terabyte),
+ (InformationUnit.Bit, InformationUnit.Byte) => new Information(_value / 8, InformationUnit.Byte),
+ (InformationUnit.Bit, InformationUnit.Exabit) => new Information((_value) / 1e18d, InformationUnit.Exabit),
+ (InformationUnit.Bit, InformationUnit.Exabyte) => new Information((_value / 8) / 1e18d, InformationUnit.Exabyte),
+ (InformationUnit.Bit, InformationUnit.Exbibit) => new Information((_value) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Exbibit),
+ (InformationUnit.Bit, InformationUnit.Exbibyte) => new Information((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Exbibyte),
+ (InformationUnit.Bit, InformationUnit.Gibibit) => new Information((_value) / (1024d * 1024 * 1024), InformationUnit.Gibibit),
+ (InformationUnit.Bit, InformationUnit.Gibibyte) => new Information((_value / 8) / (1024d * 1024 * 1024), InformationUnit.Gibibyte),
+ (InformationUnit.Bit, InformationUnit.Gigabit) => new Information((_value) / 1e9d, InformationUnit.Gigabit),
+ (InformationUnit.Bit, InformationUnit.Gigabyte) => new Information((_value / 8) / 1e9d, InformationUnit.Gigabyte),
+ (InformationUnit.Bit, InformationUnit.Kibibit) => new Information((_value) / 1024d, InformationUnit.Kibibit),
+ (InformationUnit.Bit, InformationUnit.Kibibyte) => new Information((_value / 8) / 1024d, InformationUnit.Kibibyte),
+ (InformationUnit.Bit, InformationUnit.Kilobit) => new Information((_value) / 1e3d, InformationUnit.Kilobit),
+ (InformationUnit.Bit, InformationUnit.Kilobyte) => new Information((_value / 8) / 1e3d, InformationUnit.Kilobyte),
+ (InformationUnit.Bit, InformationUnit.Mebibit) => new Information((_value) / (1024d * 1024), InformationUnit.Mebibit),
+ (InformationUnit.Bit, InformationUnit.Mebibyte) => new Information((_value / 8) / (1024d * 1024), InformationUnit.Mebibyte),
+ (InformationUnit.Bit, InformationUnit.Megabit) => new Information((_value) / 1e6d, InformationUnit.Megabit),
+ (InformationUnit.Bit, InformationUnit.Megabyte) => new Information((_value / 8) / 1e6d, InformationUnit.Megabyte),
+ (InformationUnit.Bit, InformationUnit.Pebibit) => new Information((_value) / (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Pebibit),
+ (InformationUnit.Bit, InformationUnit.Pebibyte) => new Information((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Pebibyte),
+ (InformationUnit.Bit, InformationUnit.Petabit) => new Information((_value) / 1e15d, InformationUnit.Petabit),
+ (InformationUnit.Bit, InformationUnit.Petabyte) => new Information((_value / 8) / 1e15d, InformationUnit.Petabyte),
+ (InformationUnit.Bit, InformationUnit.Tebibit) => new Information((_value) / (1024d * 1024 * 1024 * 1024), InformationUnit.Tebibit),
+ (InformationUnit.Bit, InformationUnit.Tebibyte) => new Information((_value / 8) / (1024d * 1024 * 1024 * 1024), InformationUnit.Tebibyte),
+ (InformationUnit.Bit, InformationUnit.Terabit) => new Information((_value) / 1e12d, InformationUnit.Terabit),
+ (InformationUnit.Bit, InformationUnit.Terabyte) => new Information((_value / 8) / 1e12d, InformationUnit.Terabyte),
_ => null
};
@@ -1282,7 +1270,7 @@ public Information ToUnit(UnitSystem unitSystem)
IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
///
- IValueQuantity IValueQuantity.ToUnit(Enum unit)
+ IValueQuantity IValueQuantity.ToUnit(Enum unit)
{
if (unit is not InformationUnit typedUnit)
throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit));
@@ -1291,7 +1279,7 @@ IValueQuantity IValueQuantity.ToUnit(Enum unit)
}
///
- IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
+ IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
#endregion
diff --git a/UnitsNet/IDecimalQuantity.cs b/UnitsNet/IDecimalQuantity.cs
deleted file mode 100644
index 31fe515ac6..0000000000
--- a/UnitsNet/IDecimalQuantity.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed under MIT No Attribution, see LICENSE file at the root.
-// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
-
-using System;
-
-namespace UnitsNet
-{
- ///
- /// Represents a quantity with a decimal value.
- ///
- ///
- /// This interface is obsolete. Please use
- ///
- [Obsolete("Use the IValueQuantity interface.")]
- public interface IDecimalQuantity : IValueQuantity
- {
- }
-}