0

np.log(someMatrix) generates values of the type 1.220536239336080619e+01. I'd like actually see all the digits intead of +e01. Is there a way to tell numpy to do so please?

I tried around() but doesn't work for me.

2
  • Why do you say you're not seeing "all the digits"? If you've got huge numbers, don't forget that floating-point numbers have limited precision, so the ones place on an e+20 float is essentially noise. Commented Mar 5, 2016 at 8:53
  • A float double has a max 52 bits of precision, you can check how many you have with something like len(bin(<int>)) if you print it via. one of the answers suggested below. For example the number in your question would take 63 bits to represent exactly. Commented Mar 5, 2016 at 9:19

3 Answers 3

1

You can see as many digits of a float as you want with a formatted print. But I agree with user2357112, the last digits may be out of precision limits and are not significant.

r=1.220536239336080619e+01
print "%-.24f"%(r)

12.205362393360806194664292
Sign up to request clarification or add additional context in comments.

Comments

1

when you write your data to file, you can choose between different formattings, %f is the one, that don't use exponential notation:

np.savetxt('matrix.txt', np.log(someMatrix), '%f')

Comments

1

You can use np.array2str with a formatter that displays it as number without decimals:

import numpy as np
a = np.array([1434e24])
np.array2string(a, formatter={'float_kind':lambda x: "%.0f" % x})
# prints '[1433999999999999897558319104]'

notice however that the number is dominated by the floating point precision and therefore will not be exactly what you typed in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.