Commit fc119171 authored by Littichai Buddaken's avatar Littichai Buddaken

finished week04/assignment

parent 19a37f1d
def single_prec(V): def single_prec(V):
"""แบบ IEE sigle precision format""" """แบบ 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)]) 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""" """แบบ 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)]) 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