On 2007-05-09, Terry Reedy <[EMAIL PROTECTED]> wrote: >| I'm pretty sure the answer is "no", but before I give up on the >| idea, I thought I'd ask... >| >| Is there any way to do single-precision floating point >| calculations in Python? > > Make your own Python build from altered source. And run it on > an ancient processor/OS/C compiler combination that does not > automatically convert C floats to double when doing any sort > of calculation.
It wouldn't have to be that ancient. The current version of gcc supports 32-bit doubles on quite a few platforms -- though it doesn't seem to for IA32 :/ Simply storing intermediate and final results as single-precision floats would probably be sufficient. > Standard CPython does not have C single-precision floats. I know. > The only point I can think of for doing this with single numbers, as > opposed to arrays of millions, is to show that there is no point. I use Python to test algorithms before implementing them in C. It's far, far easier to do experimentation/prototyping in Python than in C. I also like to have two sort-of independent implementations to test against each other (it's a good way to catch typos). In the C implementations, the algorithms will be done implemented in single precision, so doing my Python prototyping in as close to single precision as possible would be "a good thing". > Or do you have something else in mind? -- Grant Edwards grante Yow! Yow! Is my fallout at shelter termite proof? visi.com -- http://mail.python.org/mailman/listinfo/python-list