Skip to content

Commit

Permalink
Fixed bug in json formatted floating point.
Browse files Browse the repository at this point in the history
  • Loading branch information
esitarski committed Jun 14, 2023
1 parent 6e2f47c commit b2be3f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions MainWin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,9 +2029,14 @@ def sanitize( template ):
def fixBigFloat( f ):
if len(f) > 6:
try:
d = f.split('.')[1]
return '{:.5f}'.format(float(f)).rstrip('0') if len(d) > 5 else f
d = f.split('.')[1] # Get decimal part of the number.
max_precision = 5
if len(d) > max_precision:
f = '{val:.{pr}f}'.format(pr=max_precision, val=float(f)).rstrip('0') # Reformat with a shorter decimal and remove trailing zeros.
if f.endswith('.'):
f += '0' # Ensure a zero follows the decimal point (json format spec).
except IndexError:
# Number does not have a decimal point.
pass
return f

Expand Down
2 changes: 1 addition & 1 deletion Version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AppVerName="CrossMgr 3.1.28-private"
AppVerName="CrossMgr 3.1.29-private"

0 comments on commit b2be3f4

Please sign in to comment.