** converts an integer to a "floating point byte", represented as ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if ** eeeee != 0 and (xxx) otherwise. */
| 33 | ** eeeee != 0 and (xxx) otherwise. |
| 34 | */ |
| 35 | int luaO_int2fb (unsigned int x) { |
| 36 | int e = 0; /* expoent */ |
| 37 | while (x >= 16) { |
| 38 | x = (x+1) >> 1; |
| 39 | e++; |
| 40 | } |
| 41 | if (x < 8) return x; |
| 42 | else return ((e+1) << 3) | (cast_int(x) - 8); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | /* converts back */ |