Commit 27e7d18c authored by sumet's avatar sumet Committed by Kittisak Maneewong

ส่งงานครับ

parents
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
def value(v,p=4,n=3):
sign = -1 if v[0] == 1 else 1
return sign * sum([v[i] * (2 ** (p - i)) for i in range(1, p+n+1)])
def values(V,p=4,n=3):
v = list(map(int,V))
sign = -1 if v[0] == 1 else 1
return sign * sum([v[i] * (2 ** (p - i)) for i in range(1, p + n + 1)])
\ No newline at end of file
#งาน week04
def single_prec(v):
v+="0"*(32-len(v))
return (-1)**int(v[0])*sum([int(v[i])* (2 ** (8 - i)) for i in range(1,32)])
def double_prec(v):
v+="0"*(64-len(v))
return (-1)**int(v[0])*sum([int(v[i]) * (2 ** (11 - i)) for i in range(1, 64)])
\ No newline at end of file
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