Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local exponent = 4
- local biased_exp = 1027
- print("Exponent: ".. exponent, "biased exp: ".. biased_exp)
- for i = 10, 0, -1 do
- local bitvalue = 2^i
- print("\t".."Exponent bit: ".. i)
- if i > 3 and biased_exp >= bitvalue then
- print("\t\t".."Exponent is bigger than bitvalue: ".. biased_exp .. ">=".. bitvalue, "2^"..(i-4))
- ---
- local bexp_int, bexp_fra = math.modf(biased_exp)
- local bitval_int, bitval_fra = math.modf(bitvalue)
- print("\t\t".."Biased exp int: ".. bexp_int, "fraction: ".. bexp_fra)
- print("\t\t".."Bitval int: ".. bitval_int, "fraction: ".. bitval_fra)
- print("\t\t".."==", bexp_int == bitval_int, bexp_frac == bitval_frac)
- print("\t\t"..">=", bexp_int >= bitval_int, bexp_frac >= bitval_frac)
- print("\t\t".."> ", bexp_int > bitval_int, bexp_frac > bitval_frac)
- ---
- biased_exp = biased_exp - bitvalue
- elseif exponent >= bitvalue then
- print("Exponent is bigger than bitvalue: ".. biased_exp .. ">=".. bitvalue, "2^"..(i+4))
- biased_exp = biased_exp - bitvalue
- end
- end
- print("Biased Exponent should equal zero: ".. biased_exp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement