mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Minor cleanup
This commit is contained in:
parent
9dedabfa71
commit
fb61e00780
1 changed files with 12 additions and 8 deletions
|
@ -368,12 +368,12 @@ def v2f(v):
|
||||||
return v
|
return v
|
||||||
return Vector((ff(v[0]), ff(v[1]), ff(v[2])))
|
return Vector((ff(v[0]), ff(v[1]), ff(v[2])))
|
||||||
|
|
||||||
def f2s(val, DP=6, SignedZero=True):
|
def f2s(val, DP=6):
|
||||||
if math.isinf(val):
|
if math.isinf(val):
|
||||||
return u'Infinity' if val > 0 else u'-Infinity'
|
return u'Infinity' if val > 0 else u'-Infinity'
|
||||||
if math.isnan(val):
|
if math.isnan(val):
|
||||||
return u'NaN'
|
return u'NaN'
|
||||||
if lslcommon.LSO or SignedZero and val == 0.:
|
if lslcommon.LSO or val == 0.:
|
||||||
return u'%.*f' % (DP, val) # deals with -0.0 too
|
return u'%.*f' % (DP, val) # deals with -0.0 too
|
||||||
|
|
||||||
# Format according to Mono rules. Mono displays 7 significant decimal
|
# Format according to Mono rules. Mono displays 7 significant decimal
|
||||||
|
@ -685,6 +685,16 @@ def InternalGetDeleteSubSequence(val, start, end, isGet):
|
||||||
return val[:end+1] + val[start:] if isGet else val[end+1:start]
|
return val[:end+1] + val[start:] if isGet else val[end+1:start]
|
||||||
return val[start:end+1] if isGet else val[:start] + val[end+1:]
|
return val[start:end+1] if isGet else val[:start] + val[end+1:]
|
||||||
|
|
||||||
|
def reduce(t):
|
||||||
|
t = F32(t)
|
||||||
|
if not t.is_integer():
|
||||||
|
return t # Accurate-ish until big numbers come into play
|
||||||
|
return int(t * 18446744073709551616) % 115904311329233965478 / 18446744073709551616.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Functions for LSL-compatible operators
|
||||||
|
#
|
||||||
|
|
||||||
def typecast(val, out, InList=False, f32=True):
|
def typecast(val, out, InList=False, f32=True):
|
||||||
"""Type cast an item. Calls InternalList2Strings for lists and
|
"""Type cast an item. Calls InternalList2Strings for lists and
|
||||||
defers the rest to InternalTypecast.
|
defers the rest to InternalTypecast.
|
||||||
|
@ -946,12 +956,6 @@ def cond(x):
|
||||||
return len(x) > 1
|
return len(x) > 1
|
||||||
return bool(x) # works fine for int, float, string, list
|
return bool(x) # works fine for int, float, string, list
|
||||||
|
|
||||||
def reduce(t):
|
|
||||||
t = F32(t)
|
|
||||||
if not t.is_integer():
|
|
||||||
return t # Accurate-ish until big numbers come into play
|
|
||||||
return int(t * 18446744073709551616) % 115904311329233965478 / 18446744073709551616.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# LSL-compatible computation functions
|
# LSL-compatible computation functions
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue