Skip to content

Commit

Permalink
.NET: Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
agdavydov81 committed Sep 20, 2023
1 parent e5e77e0 commit 89b1444
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
18 changes: 9 additions & 9 deletions csharp/EPAM.Deltix.DFP.Test/Decimal64Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public void TestParseReImpl()
{
var testStr = "000";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.Zero, value);
Expand All @@ -716,7 +716,7 @@ public void TestParseReImpl()
{
var testStr = "00..";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.NaN, value);
Expand All @@ -726,7 +726,7 @@ public void TestParseReImpl()
{
var testStr = "000235";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.FromInt(235), value);
Expand All @@ -736,7 +736,7 @@ public void TestParseReImpl()
{
var testStr = "00.0000235";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.FromFixedPoint(235, 7), value);
Expand All @@ -746,7 +746,7 @@ public void TestParseReImpl()
{
var testStr = "1234512345123451234500000";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.FromFixedPoint(1234512345123451, -9), value);
Expand All @@ -756,7 +756,7 @@ public void TestParseReImpl()
{
var testStr = "1234512345123451234500000e+12345123451234512345";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.PositiveInfinity, value);
Expand All @@ -766,7 +766,7 @@ public void TestParseReImpl()
{
var testStr = "-5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.NegativeInfinity, value);
Expand All @@ -776,7 +776,7 @@ public void TestParseReImpl()
{
var testStr = "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.Zero, value);
Expand All @@ -786,7 +786,7 @@ public void TestParseReImpl()
{
var testStr = "123 x99";
uint fpsf;
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, out fpsf, roundMode));
var value = Decimal64.FromUnderlying(DotNetReImpl.bid64_from_string(testStr, Decimal64.DecimalMarkAny, out fpsf, roundMode));
double doubleValue;
var doubleParseOk = Double.TryParse(testStr, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue);
Assert.AreEqual(Decimal64.NaN, value);
Expand Down
38 changes: 35 additions & 3 deletions csharp/EPAM.Deltix.DFP/Decimal64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,18 @@ public Decimal64 Canonize()
public static Decimal64 Parse(String text)
{
uint fpsf;
var ret = DotNetReImpl.bid64_from_string(text, out fpsf);
var ret = DotNetReImpl.bid64_from_string(text, DecimalMarkAny, out fpsf);
if ((fpsf & DotNetReImpl.BID_INVALID_FORMAT) != 0)
throw new FormatException("Input string is not in a correct format.");
//else if ((fpsf & DotNetReImpl.BID_INEXACT_EXCEPTION) != 0)
// throw new FormatException("Can't convert input string to value without precision loss.");
return FromUnderlying(ret);
}

public static Decimal64 Parse(String text, String decimalMarks)
{
uint fpsf;
var ret = DotNetReImpl.bid64_from_string(text, decimalMarks, out fpsf);
if ((fpsf & DotNetReImpl.BID_INVALID_FORMAT) != 0)
throw new FormatException("Input string is not in a correct format.");
//else if ((fpsf & DotNetReImpl.BID_INEXACT_EXCEPTION) != 0)
Expand All @@ -976,15 +987,36 @@ public enum StatusValue
public static Boolean TryParse(String text, out Decimal64 result, out StatusValue status)
{
uint fpsf;
result = FromUnderlying(DotNetReImpl.bid64_from_string(text, out fpsf));
result = FromUnderlying(DotNetReImpl.bid64_from_string(text, DecimalMarkAny, out fpsf));
status = (StatusValue)fpsf;
return status == StatusValue.Exact;
}

public static Boolean TryParse(String text, String decimalMarks, out Decimal64 result, out StatusValue status)
{
uint fpsf;
result = FromUnderlying(DotNetReImpl.bid64_from_string(text, decimalMarks, out fpsf));
status = (StatusValue)fpsf;
return status == StatusValue.Exact;
}

public static Boolean TryParse(String text, out Decimal64 result)
{
uint fpsf;
var ret = DotNetReImpl.bid64_from_string(text, out fpsf);
var ret = DotNetReImpl.bid64_from_string(text, DecimalMarkAny, out fpsf);
if ((fpsf & DotNetReImpl.BID_INVALID_FORMAT) != 0)
{
result = NaN;
return false;
}
result = FromUnderlying(ret);
return true;
}

public static Boolean TryParse(String text, String decimalMarks, out Decimal64 result)
{
uint fpsf;
var ret = DotNetReImpl.bid64_from_string(text, decimalMarks, out fpsf);
if ((fpsf & DotNetReImpl.BID_INVALID_FORMAT) != 0)
{
result = NaN;
Expand Down
2 changes: 1 addition & 1 deletion csharp/EPAM.Deltix.DFP/DotNetReImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private unsafe static bool IsStrEq(char* ptr, string str)
}
}

public unsafe static BID_UINT64 bid64_from_string(string s, out _IDEC_flags pfpsf, string decimalMarks, int rnd_mode = BID_ROUNDING_TO_NEAREST/*, _EXC_MASKS_PARAM _EXC_INFO_PARAM*/)
public unsafe static BID_UINT64 bid64_from_string(string s, string decimalMarks, out _IDEC_flags pfpsf, int rnd_mode = BID_ROUNDING_TO_NEAREST/*, _EXC_MASKS_PARAM _EXC_INFO_PARAM*/)
{

BID_UINT64 coefficient_x = 0, rounded = 0;
Expand Down

0 comments on commit 89b1444

Please sign in to comment.