[Numpy-discussion] Fixed-point arithemetic...any solution yet?
Thu Dec 10 18:09:23 CST 2009
not to mention that that idea probably isnt going to work if his
problem is non-linear ;)
On Thu, Dec 10, 2009 at 7:36 PM, Norbert Nemec
> Dag Sverre Seljebotn wrote:
>> I haven't heard of anything, but here's what I'd do:
>> - Use np.int64
>> - Multiply all inputs to my code with 10^6
>> - Divide all output from my code with 10^6
>> - If you need to debug-print and array, simply define something like
>> FIXED_POINT_FACTOR = 10**6
>> def printarr(x):
>> print x.astype(np.float) / FIXED_POINT_FACTOR
>> Or am I missing something?
> Indeed, you are missing that internal multiplications have to take into
> account this factor as well. To prevent loss of precision, you would
> need int128 results and shift those correctly after the multiplication.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion