Skip to content

Commit

Permalink
Fixes negative zero decimals. (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonz-bq authored Mar 12, 2020
1 parent fa789f5 commit 0a21f54
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Amazon.IonDotnet.Tests/Amazon.IonDotnet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="'$(OS)' != 'Unix'">netcoreapp2.1;netcoreapp2.0;netcoreapp1.0;net45;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Unix'">netcoreapp2.1;net45;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<Configurations>Debug;Release;Perf</Configurations>
Expand Down
3 changes: 3 additions & 0 deletions Amazon.IonDotnet.Tests/Internals/BigDecimalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ public void Parse_Zeros(string text, bool isNegativeZero)
[DataRow("0.12345d5", "12345d0")]
[DataRow("0.12345d4", "1234.5")]
[DataRow("12345d-5", "1.2345d-1")]
[DataRow("-0d5", "-0d5")]
[DataRow("-0d-5", "-0d-5")]
[DataRow("-0.00d7", "-0d5")]
public void ToString_Simple(string text, string expected)
{
var parsed = BigDecimal.Parse(text);
Expand Down
3 changes: 1 addition & 2 deletions Amazon.IonDotnet/BigDecimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,9 @@ public static BigDecimal Parse(ReadOnlySpan<char> text)

public override string ToString()
{
//TODO improve this
if (IsNegativeZero)
{
return "-0d" + Scale;
return "-0d" + (-Scale);
}

var sb = new StringBuilder(IntVal.ToString(CultureInfo.InvariantCulture));
Expand Down
3 changes: 0 additions & 3 deletions Amazon.IonDotnet/Internals/Binary/RawBinaryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,13 +919,10 @@ private ContainerType GetContainerType(IonType ionType)
{
case IonType.List:
return ContainerType.List;
break;
case IonType.Struct:
return ContainerType.Struct;
break;
case IonType.Sexp:
return ContainerType.Sexp;
break;
default:
throw new ArgumentOutOfRangeException();
}
Expand Down

0 comments on commit 0a21f54

Please sign in to comment.