Skip to content

Commit 9039c5f

Browse files
Support the maximum precision for decimals at dfwpnum. (#899)
* Support the maximum precision for decimals at dfwpnum. * Fix error in test.
1 parent cdf2e22 commit 9039c5f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,15 @@ public short dfwnext()
771771
return GX_ASCDEL_WRITEERROR;
772772
}
773773
}
774+
const int MAX_DECIMAL_PRECISION = 29;
774775
public short dfwpnum(decimal num, int dec)
775776
{
776777
if (_writeStatus == FileIOStatus.Closed)
777778
{
778779
GXLogging.Error(log, "Error ADF0004");
779780
return GX_ASCDEL_INVALIDSEQUENCE;
780781
}
781-
appendFld(StringUtil.Str(num, 18, dec).TrimStart(null));
782+
appendFld(StringUtil.Str(num, MAX_DECIMAL_PRECISION, dec).TrimStart(null));
782783
return GX_ASCDEL_SUCCESS;
783784
}
784785
public short dfwptxt(string s, int len)

dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ public class DfrgFunctions : FileSystemTest
1010
const string APPLICATIONS_CONTENT = "[ { \"Id\": \"4caaaed5-1160-4132-b54f-0191e527a84a\", \"Type\": 1, \"EnvironmentGUID\": \"b3730606-0f2a-4e8a-b395-d8fdf226def8\", \"IsNew\": false }]";
1111
const string DOCUMENT_CONTENT = "Line 1Line 2Line 3";
1212
const string MS923_CONTENT = "1234567890123";
13+
14+
[Fact]
15+
public void dfwpnumTest()
16+
{
17+
GxContext context = new GxContext();
18+
string fileName = Path.Combine(BaseDir, "dfwpnumTest.txt");
19+
context.FileIOInstance.dfwopen(fileName, ",", "\"", 0, "UTF-8");
20+
context.FileIOInstance.dfwpnum(99999999999999999.5M, 5);
21+
context.FileIOInstance.dfwnext();
22+
context.FileIOInstance.dfwclose();
23+
24+
string content = File.ReadAllText(fileName);
25+
Assert.Contains("99999999999999999.5", content, StringComparison.OrdinalIgnoreCase);
26+
}
1327
[Fact]
1428
public void dfrgtxtANSITest()
1529
{

0 commit comments

Comments
 (0)