Fix bug with reduction, and remove useless code.

Oops, we have to reduce *after* testing for range!

Also, the special cases for the tangent are unnecessary, because the results are already correct.
This commit is contained in:
Sei Lisa 2016-05-21 04:16:34 +02:00
parent 9cf9478270
commit 51a7e6d199

View file

@ -934,11 +934,11 @@ def llCeil(f):
def llCos(f): def llCos(f):
assert isfloat(f) assert isfloat(f)
f = reduce(ff(f)) f = ff(f)
if math.isinf(f): if math.isinf(f):
return Indet return Indet
if -9223372036854775808.0 < f < 9223372036854775808.0: if -9223372036854775808.0 < f < 9223372036854775808.0:
return F32(math.cos(f)) return F32(math.cos(reduce(f)))
return f return f
def llDeleteSubList(lst, start, end): def llDeleteSubList(lst, start, end):
@ -1562,11 +1562,11 @@ def llSHA1String(s):
def llSin(f): def llSin(f):
assert isfloat(f) assert isfloat(f)
f = reduce(ff(f)) f = ff(f)
if math.isinf(f): if math.isinf(f):
return Indet return Indet
if -9223372036854775808.0 < f < 9223372036854775808.0: if -9223372036854775808.0 < f < 9223372036854775808.0:
return F32(math.sin(f)) return F32(math.sin(reduce(f)))
return f return f
def llSqrt(f): def llSqrt(f):
@ -1606,16 +1606,11 @@ def llSubStringIndex(s, pattern):
def llTan(f): def llTan(f):
assert isfloat(f) assert isfloat(f)
f = reduce(ff(f)) f = ff(f)
if math.isinf(f): if math.isinf(f):
return Indet return Indet
if -9223372036854775808.0 < f < 9223372036854775808.0: if -9223372036854775808.0 < f < 9223372036854775808.0:
# We only consider the first turn for anomalous results. return F32(math.tan(reduce(f)))
if abs(f) == 1.570796251296997:
return math.copysign(13245402.0, f);
if abs(f) == 1.5707963705062866:
return -math.copysign(22877332.0, f);
return F32(math.tan(f))
return f return f
def llToLower(s): def llToLower(s):