Skip to content

Commit c2b3099

Browse files
author
Oren (electricessence)
committed
Updated packaging.
1 parent 2751d46 commit c2b3099

File tree

5 files changed

+46
-84
lines changed

5 files changed

+46
-84
lines changed

LISCENSE.md renamed to LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
## Copyright (c) 2017 Oren J. Ferrari
3+
## Copyright (c) 2020 electricessence (Oren F.) All rights reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

Numeric.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
/*!
2-
* @author electricessence / https://github.com/electricessence/
3-
* Licensing: MIT https://github.com/electricessence/Open/blob/dotnet-core/LICENSE.md
4-
*/
5-
6-
using Open.Numeric.Precision;
1+
using Open.Numeric.Precision;
72
using System;
83

9-
104
namespace Open.Numeric
115
{
126
public static class Extensions
@@ -41,7 +35,7 @@ public static class NumericConvert
4135
/// </summary>
4236
public static double ToDouble(object value)
4337
{
44-
if (value == null)
38+
if (value is null)
4539
return double.NaN;
4640

4741
return value is float f

Open.Numeric.csproj

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,49 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5+
<LangVersion>latest</LangVersion>
6+
<Nullable>enable</Nullable>
7+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
58
<Authors>electricessence</Authors>
6-
<Company />
7-
<Product />
89
<Description>
910
Extensions for simplifying working with numbers.
1011
Includes precision extensions for floating point numbers.
1112

1213
Part of the "Open" set of libraries.
1314
</Description>
14-
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
15-
<PackageLicenseUrl></PackageLicenseUrl>
16-
<Copyright>https://github.com/electricessence/Open.Numeric/blob/master/LISCENSE.md</Copyright>
17-
<RepositoryUrl>https://github.com/electricessence/Open.Numeric/</RepositoryUrl>
18-
<PackageProjectUrl>https://github.com/electricessence/Open.Numeric/</PackageProjectUrl>
15+
<PackageTags>numbers;double;float;precision;extensions</PackageTags>
16+
<Copyright>© electricessence (Oren F.) All rights reserved.</Copyright>
17+
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.Numeric/</RepositoryUrl>
18+
<PackageProjectUrl>https://github.com/Open-NET-Libraries/Open.Numeric/</PackageProjectUrl>
1919
<RepositoryType>git</RepositoryType>
20-
<PackageTags>dotnet, dotnetcore, cs, numbers, double, float, precision, extensions</PackageTags>
21-
<Version>2.2.2</Version>
20+
<Version>2.3.0</Version>
2221
<PackageReleaseNotes></PackageReleaseNotes>
2322
<PackageLicenseExpression>MIT</PackageLicenseExpression>
24-
<Nullable>enable</Nullable>
25-
26-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
27-
<IncludeSymbols>true</IncludeSymbols>
28-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
23+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
24+
<IncludeSymbols>true</IncludeSymbols>
25+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
26+
<PackageIcon>logo.png</PackageIcon>
2927
</PropertyGroup>
3028

3129
<ItemGroup>
3230
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
3331
</ItemGroup>
3432

35-
36-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
37-
<Optimize>True</Optimize>
38-
<LangVersion>latest</LangVersion>
39-
</PropertyGroup>
40-
41-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
42-
<LangVersion>latest</LangVersion>
43-
</PropertyGroup>
44-
4533
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
46-
<PackageReference Include="System.Memory" Version="4.5.3" />
34+
<PackageReference Include="System.Memory" Version="4.5.4" />
4735
</ItemGroup>
4836

4937
<ItemGroup>
5038
<None Remove=".git" />
5139
<None Remove=".gitignore" />
52-
<None Remove="LISCENSE.md" />
53-
<None Remove="README.md" />
40+
<None Include="logo.png">
41+
<Pack>True</Pack>
42+
<PackagePath></PackagePath>
43+
</None>
5444
</ItemGroup>
5545

5646
<ItemGroup>
57-
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
47+
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
5848
</ItemGroup>
5949

6050
</Project>

Precision.cs

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,30 @@ public static class PrecisionExtensions
1111
/// Accurate way to convert float to decimal by converting to string first. Avoids tolerance issues.
1212
/// </summary>
1313
public static decimal ToDecimal(this float value)
14-
{
15-
return decimal.Parse(value.ToString(CultureInfo.InvariantCulture));
16-
}
14+
=> decimal.Parse(value.ToString(CultureInfo.InvariantCulture));
1715

1816
/// <summary>
1917
/// Shortcut for validating a if a floating point value is considered zero (within epsilon tolerance).
2018
/// </summary>
21-
public static bool IsZero(this float value)
22-
{
23-
return IsPreciseEqual(value, 0f);
24-
}
19+
public static bool IsZero(this float value) => IsPreciseEqual(value, 0f);
2520

2621
/// <summary>
2722
/// Shortcut for validating a if a double tolerance floating point value is considered zero (within epsilon tolerance).
2823
/// </summary>
29-
public static bool IsZero(this double value)
30-
{
31-
return IsPreciseEqual(value, 0d);
32-
}
24+
public static bool IsZero(this double value) => IsPreciseEqual(value, 0d);
3325

3426

3527
/// <summary>
3628
/// Shortcut for validating a if a double tolerance floating point value is considered zero (within provided tolerance).
3729
/// </summary>
3830
public static bool IsNearZero(this double value, double precision = 0.001)
39-
{
40-
return IsNearEqual(value, 0d, precision);
41-
}
31+
=> IsNearEqual(value, 0d, precision);
4232

4333
/// <summary>
4434
/// Shortcut for returning true zero if a double tolerance floating point value is considered zero (within epsilon tolerance).
4535
/// </summary>
4636
public static double FixZero(this double value)
47-
{
48-
return !value.Equals(0) && value.IsZero() ? 0 : value;
49-
}
37+
=> !value.Equals(0) && value.IsZero() ? 0 : value;
5038

5139
static double ReturnZeroIfFinite(this float value)
5240
{
@@ -78,25 +66,24 @@ public static int DecimalPlaces(this double source)
7866
/// Shortcut for validating a if a floating point value is close enough to another addValue using the given tolerance tolerance.
7967
/// </summary>
8068
public static bool IsNearEqual(this float a, float b, float tolerance)
81-
{
82-
return a.Equals(b) || float.IsNaN(a) && float.IsNaN(b) || Math.Abs(a - b) < tolerance;
83-
}
69+
=> a.Equals(b)
70+
|| float.IsNaN(a) && float.IsNaN(b)
71+
|| Math.Abs(a - b) < tolerance;
8472

8573
/// <summary>
8674
/// Shortcut for validating a if a double precision floating point value is close enough to another addValue using the given tolerance tolerance.
8775
/// </summary>
8876
public static bool IsNearEqual(this double a, double b, double tolerance)
89-
{
90-
return a.Equals(b) || double.IsNaN(a) && double.IsNaN(b) || Math.Abs(a - b) < tolerance;
91-
}
77+
=> a.Equals(b)
78+
|| double.IsNaN(a) && double.IsNaN(b)
79+
|| Math.Abs(a - b) < tolerance;
9280

9381
/// <summary>
9482
/// Shortcut for validating a if a decimal addValue is close enough to another addValue using the given tolerance tolerance.
9583
/// </summary>
9684
public static bool IsNearEqual(this decimal a, decimal b, decimal tolerance)
97-
{
98-
return a.Equals(b) || Math.Abs(a - b) < tolerance;
99-
}
85+
=> a.Equals(b)
86+
|| Math.Abs(a - b) < tolerance;
10087

10188
/// <summary>
10289
/// Shortcut for validating a if a decimal addValue is close enough to another addValue using the given tolerance tolerance.
@@ -117,46 +104,39 @@ public static bool IsRelativeNearEqual(this double a, double b, uint minDecimalP
117104
/// Validates if values are equal within epsilon tolerance.
118105
/// </summary>
119106
public static bool IsPreciseEqual(this double a, double b, bool stringValidate = false)
120-
{
121-
return IsNearEqual(a, b, double.Epsilon)
122-
|| (stringValidate && !double.IsNaN(a) && !double.IsNaN(b) && a.ToString(CultureInfo.InvariantCulture) == b.ToString(CultureInfo.InvariantCulture));
123-
}
107+
=> IsNearEqual(a, b, double.Epsilon)
108+
|| (stringValidate && !double.IsNaN(a) && !double.IsNaN(b) && a.ToString(CultureInfo.InvariantCulture) == b.ToString(CultureInfo.InvariantCulture));
124109

125110

126111
/// <summary>
127112
/// Validates if values are equal within epsilon tolerance.
128113
/// </summary>
129114
public static bool IsPreciseEqual(this float a, float b, bool stringValidate = false)
130-
{
131-
return IsNearEqual(a, b, float.Epsilon) || (stringValidate && !float.IsNaN(a) && !float.IsNaN(b) && a.ToString(CultureInfo.InvariantCulture) == b.ToString(CultureInfo.InvariantCulture));
132-
}
115+
=> IsNearEqual(a, b, float.Epsilon)
116+
|| (stringValidate && !float.IsNaN(a) && !float.IsNaN(b) && a.ToString(CultureInfo.InvariantCulture) == b.ToString(CultureInfo.InvariantCulture));
133117

134118
/// <summary>
135119
/// Validates if values are equal within epsilon tolerance.
136120
/// </summary>
137121
public static bool IsPreciseEqual(this double? a, double? b, bool stringValidate = false)
138-
{
139-
return !a.HasValue && !b.HasValue || a.HasValue && b.HasValue && a.Value.IsPreciseEqual(b.Value, stringValidate);
140-
}
122+
=> !a.HasValue && !b.HasValue
123+
|| a.HasValue && b.HasValue && a.Value.IsPreciseEqual(b.Value, stringValidate);
141124

142125
/// <summary>
143126
/// Validates if values are equal within epsilon tolerance.
144127
/// </summary>
145128
public static bool IsPreciseEqual(this float? a, float? b, bool stringValidate = false)
146-
{
147-
return !a.HasValue && !b.HasValue || a.HasValue && b.HasValue && a.Value.IsPreciseEqual(b.Value, stringValidate);
148-
}
149-
150-
129+
=> !a.HasValue && !b.HasValue
130+
|| a.HasValue && b.HasValue && a.Value.IsPreciseEqual(b.Value, stringValidate);
151131

152132
/// <summary>
153133
/// Shortcut for validating a if a potential floating pointvalue is close enough to another addValue using the given tolerance tolerance.
154134
/// </summary>
155135
public static bool IsNearEqual(this IComparable a, IComparable b, IComparable tolerance)
156136
{
157-
if (a == null)
137+
if (a is null)
158138
throw new NullReferenceException();
159-
if (b == null)
139+
if (b is null)
160140
throw new ArgumentNullException(nameof(b));
161141
Contract.EndContractBlock();
162142

@@ -201,9 +181,7 @@ public static double ToDouble(this float value)
201181
/// Accurate way to convert possible float to double by converting to string first. Avoids tolerance issues.
202182
/// </summary>
203183
public static double ToDouble(this float? value)
204-
{
205-
return value?.ToDouble() ?? double.NaN;
206-
}
184+
=> value?.ToDouble() ?? double.NaN;
207185

208186

209187
/// <summary>

logo.png

54.6 KB
Loading

0 commit comments

Comments
 (0)