Python 2 では、次のようになります。
>>> var1 = 8193/4096
あなたが思っていることをしません。Python 2 では、2 つの整数を除算すると、結果として常に (切り捨てられた) 整数が返されます。
>>> 8193/4096
2
...そして、2 を呼び出すmath.ceil()
と 2 が返されます。
値の 1 つまたは両方を浮動小数点値に変換すると、好きなことが行われます。
>>> v = 8193/4096.0
>>> v
2.000244140625
>>> math.ceil(v)
3.0
代替案:
a) Python 3 に切り替えます。この場合、除算は希望どおりに動作します。
bgporter@zappa:~$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:18)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 8193/4096
2.000244140625
>>>
b) 次のように、Python 2 で Python 3 の分割を有効にします。
bgporter@varese ~:python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import division
>>> 8193/4096
2.000244140625