티스토리 뷰

decimal.getcontext().prec = 50
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
if value < decimal.Decimal(1e-9) and value > decimal.Decimal(-1e-9):

 

pi = Decimal('3.14159265358979323846264338327950288419716939937510')

def sin(x):
    x = x % (2 * pi)
    getcontext().prec += 2
    i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1
    while s != lasts:
        lasts = s
        i += 2
        fact *= i * (i - 1)
        num *= x * x
        sign *= -1
        s += num / fact * sign
    getcontext().prec -= 2
    return +s
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함