Skip to content

Commit

Permalink
DFWPNum lost pressition when bigdecimals are used (#804)
Browse files Browse the repository at this point in the history
Issue: 105261
  • Loading branch information
iroqueta committed Dec 4, 2023
1 parent 2e8882c commit d8104ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/com/genexus/CommonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,7 @@ public static String strNoRound(double value, int length, int decimals)
}


static String str(BigDecimal value, int length, int decimals, boolean round) {
public static String str(BigDecimal value, int length, int decimals, boolean round) {
if (length - 1 <= decimals)
{
// Esto es que hizo str(_, 2, 1) o str(_, 3, 2), todas cosas
Expand Down
4 changes: 3 additions & 1 deletion common/src/main/java/com/genexus/IDelimitedFilesSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public interface IDelimitedFilesSafe {
byte dfwopen(final String filename, String fdel, final String sdel, final int append, final String enc);

byte dfwnext();
byte dfwpnum(double num, int dec);
byte dfwpnum(long num, int dec);
byte dfwpnum(BigDecimal num, int dec);
byte dfwpnum(double num, int dec);
byte dfwptxt(String txt, int len);
byte dfwpdate(Date date, String fmt, String sep);
byte dfwclose();
Expand Down
17 changes: 16 additions & 1 deletion common/src/main/java/com/genexus/util/DelimitedFilesSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,27 @@ public byte dfwpnum(int num)
return 0;
}

public byte dfwpnum(long num, int dec)
{
return dfwpnum(new BigDecimal(num), dec);
}

public byte dfwpnum(BigDecimal num, int dec)
{
String doubnum = CommonUtil.ltrim(CommonUtil.str(num, 20 + dec, dec, true));
return dfwpnum(doubnum, dec);
}
public byte dfwpnum(double num, int dec)
{
String doubnum = CommonUtil.ltrim(CommonUtil.str(num, 20 + dec, dec));
return dfwpnum(doubnum, dec);
}

private byte dfwpnum(String doubnum, int dec)
{
byte retval = GX_ASCDEL_SUCCESS;
if (dfwopen_in_use)
{
String doubnum = CommonUtil.ltrim(CommonUtil.str(num, 20 + dec, dec));
int k = doubnum.indexOf(".");
if (dec == 0)
{
Expand Down

0 comments on commit d8104ec

Please sign in to comment.