Re: [Pythonmac-SIG] Re: Number format in IDE
There is much being made of the problems with computing using binary floating values, which is the default with all computer languages that I'm aware of. One of the nice things about python is that it makes it relatively easy to change the default. For instance, you could use use decimal division, which wouldn't help with cases like 1 / 3 = 0.33333..., but would allow 0.1 + 0.1 + 0.1 = 0.3 to be expressed precisely. Decimal math works through the problem just like person would on paper (or in their head), not using any of the high-speed special-purpose tools of the modern computer (floating point units), but it works and gives the answer you'd expect. The other solution, and one which keeps getting proposed for python and deferred, is rational math, where 1/3 is expressed as 1/3, not as 0.3333... (or as 0). Unfortunately, since neither of these are built-in, you either need to import a library and use them explicity, or do some fancy footwork with python at deeper levels than many of us (myself included) feel comfortable with. But if there's a real need for this, maybe we should put our heads together and figure out the best way. My opinion is that using floating point and rounding is a hack (even if calculators do it) and we should find a better solution. Of course, while these options are great for using python as a calculator, they would suck if used for a ray-tracer (you wouldn't want to use python long ints for such a beast, either). Thankfully, python gives us the flexibility to use the right tool for the job, if only we can determine what the *right* tool is. -- Dethe Elza (delza@burningtiger.com) Chief Mad Scientist Burning Tiger Technologies (http://burningtiger.com) Living Code Weblog (http://livingcode.ca)
course, while these options are great for using python as a calculator, they would suck if used for a ray-tracer (you wouldn't want to use python long ints for such a beast, either).
Not sure I follow. A ray tracer doesn't need infinite precision. Floating point ops do OK, no? After you get well below the threshold of screen and/or print resolution, who cares about more digits? Kirby
participants (2)
-
Dethe Elza
-
Kirby Urner