1
1
import sys
2
2
import math
3
+ from unicodedata import decimal
4
+
5
+ from numpy import integer
3
6
4
7
'''
5
8
A helper class for handling fixed point methods
@@ -65,8 +68,9 @@ def set_msb_bits(self, bits):
65
68
for i in range (0 , len (bits )):
66
69
if i < self .I :
67
70
self .integer_bits [i ] = bits [i ]
68
- elif i >= self .I and i < self .F :
71
+ elif i >= self .I and i < self .N :
69
72
self .decimal_bits [i - self .I ] = bits [i ]
73
+ # print('Len bits ' + str(len(bits)) + ' Inside FPU ' + str(self.integer_bits) + str(self.decimal_bits))
70
74
71
75
'''
72
76
Returns e^x, where x is the current fixed point number
@@ -77,7 +81,7 @@ def set_msb_bits(self, bits):
77
81
Notice:
78
82
- If e^x overflow, maximum value of float is used
79
83
'''
80
- def exp_float (self , sig_figs = 6 ):
84
+ def exp_float (self , sig_figs = 12 ):
81
85
try :
82
86
return round (math .exp (self .to_float ()), sig_figs )
83
87
except OverflowError :
@@ -89,7 +93,7 @@ def exp_float(self, sig_figs=6):
89
93
Returns:
90
94
- Float : 1/x, rounded some number of decimal points
91
95
'''
92
- def inv_float (self , sig_figs = 10 ):
96
+ def inv_float (self , sig_figs = 12 ):
93
97
if self .to_float ()!= 0 :
94
98
return round (1.0 / self .to_float (), sig_figs )
95
99
else :
0 commit comments