From 8a43d8ec873005c4d21011b88ac9ca7d83f73584 Mon Sep 17 00:00:00 2001 From: Chunk Date: Sat, 20 Jun 2015 19:37:45 +0800 Subject: [PATCH] cc --- .idea/Numerical.iml | 2 +- .idea/encodings.xml | 4 ++++ .idea/misc.xml | 15 ++++++++++++++- .idea/scopes/scope_settings.xml | 5 +++++ .idea/workspace.xml | 14 ++++++++++---- chap1/1_3_infiniteseries.py | 11 +++++------ 6 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 .idea/encodings.xml create mode 100644 .idea/scopes/scope_settings.xml diff --git a/.idea/Numerical.iml b/.idea/Numerical.iml index 4f21c2d..d06e659 100644 --- a/.idea/Numerical.iml +++ b/.idea/Numerical.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..d821048 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index cd9d35b..0a82ef1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,12 @@ + + + + + + @@ -10,5 +17,11 @@ - + + + + + + + \ No newline at end of file diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a39b29c..2bc51f9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -11,8 +11,8 @@ - - + + @@ -24,18 +24,24 @@ + + + - 1434792298659 + + + diff --git a/chap1/1_3_infiniteseries.py b/chap1/1_3_infiniteseries.py index 4c4ed0b..3b6d040 100644 --- a/chap1/1_3_infiniteseries.py +++ b/chap1/1_3_infiniteseries.py @@ -1,7 +1,7 @@ __author__ = 'chunk' import struct - +import numpy as np def float2bits(f, fmt='bin'): if fmt == 'hex': @@ -30,14 +30,13 @@ def double2bin(num): def infiniteseries(): - s = 0 - tmp = -1 + s = np.float32(0) + tmp = np.float32(-1) i = 0 - while float(s) != float(tmp): + while s != tmp: i += 1 tmp = s - s += float(1.0 / i) - print tmp,s + s += np.float32(1.0 / i) print i, s, tmp -- libgit2 0.21.2