@@ -61,8 +61,10 @@ def __init__(
61
61
"scaled_number_in_binary" : "" ,
62
62
"unable_to_scale" : False ,
63
63
"bias" : "" ,
64
+ "bias_in_binary" : "" ,
64
65
"exponent" : "" ,
65
66
"mantissa" : "" ,
67
+ "mantissa_base_10" : "" ,
66
68
"result" : "" ,
67
69
"hexadecimal" : "" ,
68
70
"hexadecimal_parts" : [],
@@ -229,6 +231,7 @@ def produce_output(self) -> dict:
229
231
self .output ["exponent" ] = self .exponent
230
232
self .output ["mantissa" ] = self .mantissa
231
233
self .output ["bias" ] = self .__bias
234
+ self .output ["bias_in_binary" ] = f"{ self .__bias :0{self .__exponent }b} "
232
235
self .output ["hexadecimal" ], self .output ["hexadecimal_parts" ] = self .hex ()
233
236
self .output ["result" ] = self .__str__ ()
234
237
if self .__edge_case is None :
@@ -251,6 +254,10 @@ def back_to_decimal_from_bits(self) -> (Decimal, Decimal):
251
254
Decimal representation of the number
252
255
"""
253
256
sign , exponent , mantissa = self .__str__ ().split (" " )
257
+ mantissa_base_10 = Decimal (0 )
258
+ for i in range (len (mantissa )):
259
+ mantissa_base_10 += Decimal (int (mantissa [i ]) * Decimal (2 ) ** - (i + 1 ))
260
+ self .output ["mantissa_base_10" ] = mantissa_base_10
254
261
sign = (- 1 ) ** int (sign )
255
262
exponent = int (exponent , 2 ) - self .__bias
256
263
mantissa = int (mantissa , 2 )
@@ -460,3 +467,4 @@ def octuple(x: str) -> IEEE754:
460
467
print (IEEE754 ("-Infinity" ))
461
468
print (IEEE754 ("NaN" ))
462
469
print (IEEE754 ("-NaN" ))
470
+ print (half (- 0.17 ))
0 commit comments