Skip to content

Commit

Permalink
Merge branch 'angularsen:master' into bugfix/base-dimensions/is-base-…
Browse files Browse the repository at this point in the history
…quantity
  • Loading branch information
ygorshkov authored Oct 25, 2024
2 parents d3e590e + b57ac63 commit 9326b75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 7 additions & 1 deletion UnitsNet.Tests/BaseDimensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,13 @@ public void CheckBaseDimensionMultiplicationWithForceEqualsMassTimesAcceleration
[Fact]
public void CheckToStringUsingMolarEntropy()
{
Assert.Equal("[Length]^2[Mass][Time]^-2[Temperature][Amount]", MolarEntropy.BaseDimensions.ToString());
Assert.Equal("[Length]^2[Mass][Time]^-2[Temperature]^-1[Amount]^-1", MolarEntropy.BaseDimensions.ToString());
}

[Fact]
public void CheckToStringUsingSpeed()
{
Assert.Equal("[Length][Time]^-1", Speed.BaseDimensions.ToString());
}

[Fact]
Expand Down
6 changes: 2 additions & 4 deletions UnitsNet/BaseDimensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,11 @@ public override string ToString()

private static void AppendDimensionString(StringBuilder sb, string name, int value)
{
var absoluteValue = Math.Abs(value);

if(absoluteValue > 0)
if (0 != value)
{
sb.AppendFormat("[{0}]", name);

if(absoluteValue > 1)
if (1 != value)
sb.AppendFormat("^{0}", value);
}
}
Expand Down

0 comments on commit 9326b75

Please sign in to comment.