Advertisement
VADemon

Weird Stuff. Lua

Apr 13th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local exponent = 4
  2. local biased_exp = 1027
  3. print("Exponent: ".. exponent, "biased exp: ".. biased_exp)
  4.  
  5. for i = 10, 0, -1 do
  6.     local bitvalue = 2^i
  7.     print("\t".."Exponent bit: ".. i)
  8.     if i > 3 and biased_exp >= bitvalue then
  9.         print("\t\t".."Exponent is bigger than bitvalue: ".. biased_exp .. ">=".. bitvalue, "2^"..(i-4))
  10.         ---
  11.         local bexp_int, bexp_fra = math.modf(biased_exp)
  12.         local bitval_int, bitval_fra = math.modf(bitvalue)
  13.         print("\t\t".."Biased exp int: ".. bexp_int, "fraction: ".. bexp_fra)
  14.         print("\t\t".."Bitval int: ".. bitval_int, "fraction: ".. bitval_fra)
  15.         print("\t\t".."==", bexp_int == bitval_int, bexp_frac == bitval_frac)
  16.         print("\t\t"..">=", bexp_int >= bitval_int, bexp_frac >= bitval_frac)
  17.         print("\t\t".."> ", bexp_int >  bitval_int, bexp_frac >  bitval_frac)
  18.         ---
  19.         biased_exp = biased_exp - bitvalue
  20.        
  21.     elseif exponent >= bitvalue then
  22.         print("Exponent is bigger than bitvalue: ".. biased_exp .. ">=".. bitvalue, "2^"..(i+4))
  23.        
  24.         biased_exp = biased_exp - bitvalue
  25.     end
  26. end
  27.  
  28. print("Biased Exponent should equal zero: ".. biased_exp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement