Commit 17fa7209 authored by Kittipong Maneewong's avatar Kittipong Maneewong Committed by sumet

ส่งงาน Week03

parent deda5515
def value(v,p,n):
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,n):
......@@ -6,8 +6,3 @@ def values(v,p,n):
sign = -1 if V[0]==1 else 1
return sign*sum([V[i]*(2**(p-i)) for i in range(1,p+n+1)])
v1 = [1, 0,0,1,1,1, 0,0,1,0]
print(v1)
print(value(v1,5,4))
print(values("1001110010",5,4))
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