precision error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: precision error (/thread-6590.html) |
precision error - chris64 - Nov-29-2017 How do I make 24/48 to equal 0.5? My program says that it equals 0. However, if I write it as 24.0/48 then I get the correct result. How do I change this so that my variables will have more precision? I want to write y as 24. I don't want to write it at 24.0 import math from PIL import Image import time y = 24.0 x = 48 z = y / x print z a = 24 b = 48 c = a / b print c RE: precision error - micseydel - Nov-29-2017 You can use Python 3 instead, or if you prefer Python 2, you can add from __future__ import division at the top of your script. |