Cassio Pereira
Cassio Pereira

Reputation: 439

How to set number of digits for float point output in Ipython

In octave the output of float point numbers is limited by default to 4 digits (%.4f). Is there a way to set this behavior using IPython?

Upvotes: 9

Views: 21393

Answers (3)

HRHeeb
HRHeeb

Reputation: 361

%precision also takes a format argument, eg like this (gives you 2 digit precision and non-scientific format):

%precision %.2f

Upvotes: 5

Pavan Kumar
Pavan Kumar

Reputation: 9

If you want to set the precision to 6 digits, try this:

%precision 6

Upvotes: 0

Jose
Jose

Reputation: 2129

If you are using numpy a lot, then numpy.set_printoptions lets you tweak that.

Another option is to use the magic %precision command (only in IPython 0.11 or greater).

I guess that you can put your defaults in your startup configuration file.

Upvotes: 10

Related Questions