mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Improve output of floats by minimizing them further.
This commit is contained in:
parent
649de92ebd
commit
9cf18ade60
1 changed files with 7 additions and 4 deletions
|
@ -70,14 +70,17 @@ class outscript(object):
|
|||
while s[-1] != '.' and lslfuncs.F32(float(s[:-1]+exp)) == value:
|
||||
s = s[:-1]
|
||||
if s[-1] != '.':
|
||||
news = s
|
||||
news = s[:-1]
|
||||
neg = ''
|
||||
if s[0] == '-':
|
||||
news = s[1:]
|
||||
news = news[1:]
|
||||
neg = '-'
|
||||
# Try harder
|
||||
point = news.index('.') + 1 - len(news) # Remove point
|
||||
news = str(int(news[:point-1] + news[point:]) + 1).zfill(len(news)-1) # Increment
|
||||
point = news.index('.') + 1 - len(news)
|
||||
if point:
|
||||
news = str(int(news[:point-1] + news[point:]) + 1).zfill(len(news)-1) # Increment
|
||||
else:
|
||||
news = str(int(news[:-1])+1).zfill(len(news)-1)
|
||||
news = news[:point + len(news)] + '.' + news[point + len(news):] # Reinsert point
|
||||
# Repeat the operation with the incremented number
|
||||
while news[-1] != '.' and lslfuncs.F32(float(neg+news[:-1]+exp)) == value:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue