For a (binary) floating point system of the form $(1.s_1s_2s_3)_2 2p$ that has an exponent range from $−128$ to $127$ and that uses three bits to store the significand s, what is the difference between 1 and the smallest representable number greater than one?


In [44]:
import numpy as np
A = {0: {2: 17, 3: 31}, 1: {3: 5}, 3: {1: 14}}
x = np.array([1,2,4,5])
shape=(4,4)

import numpy as np
def sparse_mv_mult(A, x, shape):
    Ax = np.zeros((shape[1],1))
    for k in list(A.keys()):
        sparse_row = A[k]
        sparse_sum = 0
        for j in list(sparse_row.keys()):
            sparse_sum += sparse_row[j]*x[j]
            Ax[k] = sparse_sum
    return Ax

Ax = sparse_mv_mult(A,x,shape)

In [45]:
Ax


Out[45]:
array([[ 223.],
       [  25.],
       [   0.],
       [  28.]])

In [39]:
def no_change(a):
    k = 1
    a = float(a)
    while a != a + 10**-k:
        k += 1
    else:
        return(k)

k = no_change(a)

In [42]:
f = (5,5)
f[1]


Out[42]:
5

In [7]:
subset[1:10]


Out[7]:
array([ 1.125,  1.25 ,  1.375,  1.5  ,  1.625,  1.75 ,  1.875,  2.   ,
        2.25 ])

largest integer


In [9]:
fp_numbers[f


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-9-b9a177fd168c> in <module>()
----> 1 fp_numbers[2048]

IndexError: index 2048 is out of bounds for axis 0 with size 2048

In [ ]: