Skip to content

Commit 395e763

Browse files
committed
Dummy commit to force build
1 parent d8104ec commit 395e763

1 file changed

Lines changed: 48 additions & 47 deletions

File tree

common/src/main/java/com/genexus/CommonUtil.java

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,66 +2923,67 @@ public static String strNoRound(double value, int length, int decimals)
29232923
}
29242924

29252925

2926-
public static String str(BigDecimal value, int length, int decimals, boolean round) {
2927-
if (length - 1 <= decimals)
2928-
{
2929-
// Esto es que hizo str(_, 2, 1) o str(_, 3, 2), todas cosas
2930-
// invalidas que implican que decimals = 0
2931-
decimals = 0;
2932-
}
2926+
public static String str(BigDecimal value, int length, int decimals, boolean round)
2927+
{
2928+
if (length - 1 <= decimals)
2929+
{
2930+
// Esto es que hizo str(_, 2, 1) o str(_, 3, 2), todas cosas
2931+
// invalidas que implican que decimals = 0
2932+
decimals = 0;
2933+
}
2934+
2935+
if (round)
2936+
{
2937+
value = CommonUtil.roundDecimal(value, decimals, BigDecimal.ROUND_HALF_UP);
2938+
}
2939+
else
2940+
{
2941+
value = CommonUtil.roundDecimal(value, decimals, BigDecimal.ROUND_DOWN);
2942+
}
2943+
2944+
String base = value.toString();
2945+
String decimalStr = "";
2946+
int decimalPos = base.indexOf('.');
29332947

2934-
if (round)
2948+
if (decimals > 0 && base.indexOf('E') == -1)
2949+
{
2950+
if (decimalPos < 0)
29352951
{
2936-
value = CommonUtil.roundDecimal(value, decimals, BigDecimal.ROUND_HALF_UP);
2952+
base += "." + replicate("0", decimals);
29372953
}
29382954
else
29392955
{
2940-
value = CommonUtil.roundDecimal(value, decimals, BigDecimal.ROUND_DOWN);
2956+
base = (decimalPos == 0?"0":base.substring(0, decimalPos)) + padr(base.substring(decimalPos), decimals + 1, "0");
29412957
}
2958+
}
29422959

2943-
String base = value.toString();
2944-
String decimalStr = "";
2945-
int decimalPos = base.indexOf('.');
2946-
2947-
if (decimals > 0 && base.indexOf('E') == -1)
2948-
{
2949-
if (decimalPos < 0)
2950-
{
2951-
base += "." + replicate("0", decimals);
2952-
}
2953-
else
2954-
{
2955-
base = (decimalPos == 0?"0":base.substring(0, decimalPos)) + padr(base.substring(decimalPos), decimals + 1, "0");
2956-
}
2957-
}
2960+
// Aca el numero tiene el valor redondeado y tiene los decimales correctos. Ahora
2961+
// hay que empezar a achicarlo si no entra en el espacio indicado.
29582962

2959-
// Aca el numero tiene el valor redondeado y tiene los decimales correctos. Ahora
2960-
// hay que empezar a achicarlo si no entra en el espacio indicado.
2963+
if (base.length() <= length)
2964+
{
2965+
return padl(base, length, " ");
2966+
}
29612967

2962-
if (base.length() <= length)
2968+
decimalPos = base.indexOf('.');
2969+
if (decimalPos > 0)
2970+
{
2971+
String integerPart = base.substring(0, decimalPos);
2972+
if (integerPart.length() <= length)
29632973
{
2964-
return padl(base, length, " ");
2974+
if (SpecificImplementation.KeepDecimals) {
2975+
int decimalsToKeep = Math.max(0, length-integerPart.length()-1);
2976+
decimalsToKeep = Math.min(decimals, decimalsToKeep);
2977+
return str(decimalVal(base, "."), length, decimalsToKeep, round);
2978+
}
2979+
else
2980+
return str(decimalVal(base, "."), length, 0, round);
29652981
}
2966-
2967-
decimalPos = base.indexOf('.');
2968-
if (decimalPos > 0)
2969-
{
2970-
String integerPart = base.substring(0, decimalPos);
2971-
if (integerPart.length() <= length)
2972-
{
2973-
if (SpecificImplementation.KeepDecimals) {
2974-
int decimalsToKeep = Math.max(0, length-integerPart.length()-1);
2975-
decimalsToKeep = Math.min(decimals, decimalsToKeep);
2976-
return str(decimalVal(base, "."), length, decimalsToKeep, round);
2977-
}
2978-
else
2979-
return str(decimalVal(base, "."), length, 0, round);
2980-
}
2981-
}
2982-
2983-
return replicate("*", length);
29842982
}
29852983

2984+
return replicate("*", length);
2985+
}
2986+
29862987
public static double round(double in, int decimals) {
29872988
return roundDecimal(DecimalUtil.unexponentString(Double.toString(in)), decimals).doubleValue();
29882989
}

0 commit comments

Comments
 (0)