Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
numer-60-2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nattapong Samanpong
numer-60-2
Commits
9592df80
Commit
9592df80
authored
Feb 01, 2018
by
Nattapong Samanpong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ทำจสก pycharm ide เป็นครั้งแรก
parent
4a6a6f91
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
1 deletion
+70
-1
Chapter 03 Numerics and Error Analysis.ipynb.ipynb
week03/Chapter 03 Numerics and Error Analysis.ipynb.ipynb
+53
-1
assignment.py
week03/assignment.py
+17
-0
No files found.
week03/Chapter 03 Numerics and Error Analysis.ipynb.ipynb
View file @
9592df80
...
...
@@ -139,6 +139,15 @@
"ยกตัวอย่างตัวเลขในเลขฐาน 2 เช่น 1, 101, 1101 เป็นต้น"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
...
...
@@ -233,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count":
15
,
"execution_count":
null
,
"metadata": {
"slideshow": {
"slide_type": "skip"
...
...
@@ -336,6 +345,49 @@
"$0.1 \\times 0.1 = 0.01 \\approx 0.0$ \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"v = [0, 0, 0, 0, 1, 1, 0, 0]\n",
"sign = -1 if v[0] == 1 else 1\n",
"value = v[1]*2**3\n",
"value += v[2]*2**2\n",
"value += v[3]*2**1\n",
"value += v[4]*2**0\n",
"\n",
"value += v[5]*2**(-1)\n",
"value += v[6]*2**(-2)\n",
"value += v[7]*2**(-3)\n",
"\n",
"print(sign*value)\n",
"[(i, 4-i) for i in range(1, 8)]\n",
"[v[i]*2**(4-i) for i in range(1, 8)]\n",
"sum([v[i]*2**(4-i) for i in range(1, 8)])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def value(v):\n",
" sign = -1 if v[0] == a else 1\n",
" return sign*sum([ v[i]*2**(4-i) for i in range(1,8)])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"v = [1, 0, 0, 1, 0, 0, 1, 1]"
]
},
{
"cell_type": "markdown",
"metadata": {
...
...
week03/assignment.py
0 → 100644
View file @
9592df80
def
value
(
v
,
pos
=
4
,
neg
=
3
):
"""รับ v มาเพื่อหาค่าเป็นเลขฐานสิบ binary --> difital.
โดยค่ากำหนกเริ่มต้น
pos เป็น 4 หลัก
neg เป็น 3 หลัก
sign bit เป็นหลักแรกเสมอ
"""
sign
=
-
1
if
v
[
0
]
==
1
else
1
return
sign
*
sum
([
v
[
i
]
*
2
**
(
pos
-
i
)
for
i
in
range
(
1
,
1
+
pos
+
neg
)])
def
values
(
v
,
pos
,
neg
):
sign
=
-
1
if
int
(
v
[
0
])
==
1
else
1
return
sign
*
sum
([
int
(
v
[
i
])
*
2
**
(
pos
-
i
)
for
i
in
range
(
1
,
1
+
pos
+
neg
)])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment