Commit 2c358181 authored by sumet's avatar sumet

ส่งงาน week04

parent fb62a644
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/numer-60-2.iml" filepath="$PROJECT_DIR$/.idea/numer-60-2.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="projectConfiguration" value="py.test" />
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module>
\ No newline at end of file
<?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.
This diff is collapsed.
def value(v,p=4,n=3): def value(v,p=4,n=3):
sign = -1 if v[0]==1 else 1 sign = -1 if v[0]==1 else 1
return sign*sum([v[i]*(2**(p-i)) for i in range(1,p+n+1)]) return sign*sum([v[i]*(2**(p-i)) for i in range(1,p+n+1)])
def values(v,p,n): def values(v,p=4,n=3):
V = list(map(int,v)) V = list(map(int,v))
sign = -1 if V[0]==1 else 1 sign = -1 if V[0]==1 else 1
return sign*sum([V[i]*(2**(p-i)) for i in range(1,p+n+1)]) return sign*sum([V[i]*(2**(p-i)) for i in range(1,p+n+1)])
......
def single_prec(v):
return ((-1) ** int(v[0])) * sum([int(v[i]) * (2 ** (8 - i)) for i in range(1,32)])
def double_prec(v):
return ((-1) ** int(v[0])) * sum([int(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