floating with many decimals in an array

0

I have a problem and that is that I have a program in python where I do calculations of different types, the fact is that one of these calculations gives me as a result a float with 16 decimals and when I store this number in an array I do not It's good.

This is the original number that gives me a certain calculation 1.2246467991473532e-16

and this is how it is stored in the array 1.2246467991473532e

which gives me conflict when accessing this number later and I can not use the round because if I truncate up to one digit before the "e" it is a completely different number than the original.

Is there any way to store this complete number in the array?

    
asked by Benji 12.02.2018 в 08:26
source

1 answer

0

for those who asked to show the code, here it is:

import numpy as np

a=1.2246467991473532e-16
matriz=np.matrix([["x","y","z",a],
                  ["x","y","z",a]])
m=[[-0.0, 0.0], [-0.30901699437494756, -0.9510565162951535], [-1.0, 1.2246467991473532e-16], [-1.3090169943749477, -0.9510565162951534]]

c=0.9510565162951535
matriz[1,0],matriz[0,1]=float(m[3][1])+c,c+float(m[3][1])



print(matriz)

result:

[['x' '1.1102230246251565e' 'z' '1.2246467991473532e-16']
 ['1.1102230246251565e' 'y' 'z' '1.2246467991473532e-16']]
    
answered by 13.02.2018 в 05:57