diff --git a/CBOR/PeterO/Cbor/CBORObject.cs b/CBOR/PeterO/Cbor/CBORObject.cs index fc03f948..540c2c39 100644 --- a/CBOR/PeterO/Cbor/CBORObject.cs +++ b/CBOR/PeterO/Cbor/CBORObject.cs @@ -2394,8 +2394,8 @@ public static CBORObject FromByte(byte value) { /// applications' purposes, and Single.NaN / Float.NaN is /// only one of these equivalent forms. In fact, /// CBORObject.FromSingle(Single.NaN) or - /// CBORObject.FromSingle(Float.NaN) could produce a CBOR-encoded - /// object that differs between DotNet and Java, because + /// CBORObject.FromSingle(Float.NaN) could produce a + /// CBOR-encoded object that differs between DotNet and Java, because /// Single.NaN / Float.NaN may have a different form in /// DotNet and Java (for example, the NaN value's sign may be negative /// in DotNet, but positive in Java). diff --git a/CBOR/PeterO/Cbor/CBORUtilities.cs b/CBOR/PeterO/Cbor/CBORUtilities.cs index 7844ba6f..d8ba5885 100644 --- a/CBOR/PeterO/Cbor/CBORUtilities.cs +++ b/CBOR/PeterO/Cbor/CBORUtilities.cs @@ -1540,7 +1540,8 @@ public static int DoubleToHalfPrecisionIfSameValue(long bits) { int newmant = unchecked((int)(mant >> 42)); return ((mant & ((1L << 42) - 1)) == 0) ? (sign | 0x7c00 | newmant) : -1; - } else if (exp == 0 && mant == 0) { // positive or negative zero always fits in half precision + } else if (exp == 0 && mant == 0) { // positive or negative zero +always fits in half precision return sign; } else if (sexp >= 31) { // overflow return -1; diff --git a/CBORTest/CBORNumberTest.cs b/CBORTest/CBORNumberTest.cs index 6ce85279..5d6a9b12 100644 --- a/CBORTest/CBORNumberTest.cs +++ b/CBORTest/CBORNumberTest.cs @@ -126,8 +126,7 @@ public void TestCanTruncatedIntFitInUInt64() { Assert.IsFalse( CBORObject.FromInt32(-99).AsNumber().CanTruncatedIntFitInUInt64()); - bool - b = + bool b = CBORObject.FromEInteger(EInteger.FromInt32(1).ShiftLeft(65)).AsNumber() .CanTruncatedIntFitInUInt64(); Assert.IsFalse(b); @@ -717,16 +716,16 @@ public void TestEncodingZeros() { TestCommon.CompareTestEqual(ToCN(0.0f), ToCN(-0.0f).Abs()); if (!CBORObject.FromDouble(0.0).AsNumber().CanFitInSingle()) { - Assert.Fail(); + Assert.Fail(); } if (!CBORObject.FromDouble(-0.0).AsNumber().CanFitInSingle()) { - Assert.Fail(); + Assert.Fail(); } if (!CBORObject.FromSingle(0.0f).AsNumber().CanFitInSingle()) { - Assert.Fail(); + Assert.Fail(); } if (!CBORObject.FromSingle(-0.0f).AsNumber().CanFitInSingle()) { - Assert.Fail(); + Assert.Fail(); } ToObjectTest.TestToFromObjectRoundTrip(0.0); @@ -734,25 +733,28 @@ public void TestEncodingZeros() { ToObjectTest.TestToFromObjectRoundTrip(-0.0); ToObjectTest.TestToFromObjectRoundTrip(-0.0f); - TestCommon.CompareTestEqual(ToCN(0.0), CBORObject.FromDouble(-0.0).AsNumber().Negate()); - TestCommon.CompareTestEqual(ToCN(-0.0), CBORObject.FromDouble(0.0).AsNumber().Negate()); - TestCommon.CompareTestEqual(ToCN(0.0f), CBORObject.FromSingle(-0.0f).AsNumber().Negate()); - TestCommon.CompareTestEqual(ToCN(-0.0f), CBORObject.FromSingle(0.0f).AsNumber().Negate()); + TestCommon.CompareTestEqual(ToCN(0.0), + CBORObject.FromDouble(-0.0).AsNumber().Negate()); + TestCommon.CompareTestEqual(ToCN(-0.0), + CBORObject.FromDouble(0.0).AsNumber().Negate()); + TestCommon.CompareTestEqual(ToCN(0.0f), + CBORObject.FromSingle(-0.0f).AsNumber().Negate()); + TestCommon.CompareTestEqual(ToCN(-0.0f), + CBORObject.FromSingle(0.0f).AsNumber().Negate()); byte[] bytes; - bytes=CBORObject.FromSingle(1.0f).EncodeToBytes(); + bytes = CBORObject.FromSingle(1.0f).EncodeToBytes(); Assert.AreEqual(3, bytes.Length); - bytes=CBORObject.FromSingle(0.0f).EncodeToBytes(); + bytes = CBORObject.FromSingle(0.0f).EncodeToBytes(); Assert.AreEqual(3, bytes.Length); - bytes=CBORObject.FromSingle(-0.0f).EncodeToBytes(); + bytes = CBORObject.FromSingle(-0.0f).EncodeToBytes(); Assert.AreEqual(3, bytes.Length); - bytes=CBORObject.FromDouble(1.0).EncodeToBytes(); + bytes = CBORObject.FromDouble(1.0).EncodeToBytes(); Assert.AreEqual(3, bytes.Length); - bytes=CBORObject.FromDouble(0.0).EncodeToBytes(); + bytes = CBORObject.FromDouble(0.0).EncodeToBytes(); Assert.AreEqual(3, bytes.Length); - bytes=CBORObject.FromDouble(-0.0).EncodeToBytes(); + bytes = CBORObject.FromDouble(-0.0).EncodeToBytes(); Assert.AreEqual(3, bytes.Length); } - } }