Commit fdfcf970 authored by Littichai Buddaken's avatar Littichai Buddaken

ส่งงาน week04

parent fc119171
def single_prec(V):
def single_prec(v):
"""แบบ IEE sigle precision format"""
if len(v) != 32 :
v+= "0"*(32-len(v))
v = list(map(int,V))
v = list(map(int,v))
return (-1)**v[0] * sum([v[i] * 2 ** (8 - i) for i in range(1, 32)])
def double_prec(V):
def double_prec(v):
"""แบบ IEE double precision format"""
if len(v) != 64 :
v+= "0"*(64-len(v))
v = list(map(int,V))
v = list(map(int,v))
return (-1)**v[0] * sum([v[i] * 2 ** (11 - i) for i in range(1, 64)])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment