[Numpy-discussion] Array printing and another question

Ken Basye kbasye1@jhu....
Tue Apr 8 10:22:33 CDT 2008

  Thanks, but it's been my experience that formatting FP numbers into 
decimal causes a lot of false alarms
all by itself; that is, you get different decimal representations of the 
same FP memory value.  I've had this happen
often enough that I found the first thing I did when an output 
difference arose was to print the FP in hex to see if the
difference was "real" or just a formatting artifact.  This formatting 
function is designed to do that all the time, while
providing enough clarity to examine values.  Here are a couple examples:
 >>> pi = 3.14159
 >>> float_to_readable_string(-100*pi)
'-(+0008)0x3a28b43958106'       # Note that the exponent is a decimal 
value with a base of 2, so "8" is 256. 
 >>> float_to_readable_string(0.0)

These strings can also be converted back to FP with absolute accuracy, 
which is almost impossible to guarantee
with decimal representations, in my experience.

Alan G Isaac wrote:
> Will set_printoptions not work for you?
> <URL:http://www.scipy.org/Numpy_Example_List_With_Doc#head-cc1302f5e9e57de71b578cf25e8a9ffd8aa3a707>
> hth,
> Alan Isaac
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion

More information about the Numpy-discussion mailing list