Properly rounding numbers for display - fix for negative numbers (#10355)

This commit is contained in:
Cardillan
2024-11-30 16:09:15 +01:00
committed by GitHub
parent a3110fde21
commit 18955d6604
2 changed files with 5 additions and 5 deletions

View File

@@ -966,8 +966,8 @@ public class LExecutor{
exec.textBuffer.append(strValue);
}else{
//display integer version when possible
if(Math.abs(value.numval - (long)(value.numval+0.5)) < 0.00001){
exec.textBuffer.append((long)(value.numval+0.5));
if(Math.abs(value.numval - Math.round(value.numval)) < 0.00001){
exec.textBuffer.append(Math.round(value.numval));
}else{
exec.textBuffer.append(value.numval);
}
@@ -1027,8 +1027,8 @@ public class LExecutor{
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, strValue);
}else{
//display integer version when possible
if(Math.abs(value.numval - (long)(value.numval+0.5)) < 0.00001){
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, (long)(value.numval+0.5) + "");
if(Math.abs(value.numval - Math.round(value.numval)) < 0.00001){
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, Math.round(value.numval) + "");
}else{
exec.textBuffer.replace(placeholderIndex, placeholderIndex + 3, value.numval + "");
}