About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 26 October 2007
Hardcopy (PDF): A4 | Letter

How can I get better precision in ChIPS output?

chips> 227.49334262014-0.0001363
227.493

For greater precision, use the S-Lang set_float_format function:

chips> 227.49334262014-0.0001363
227.493

chips> set_float_format("%g")
chips> 227.49334262014-0.0001363
227.493

chips> set_float_format("%.6e")
chips> 227.49334262014-0.0001363
2.274932e+02

chips> set_float_format("%.6f")
chips> 227.49334262014-0.0001363
227.493206

chips> set_float_format("%.12f")
chips> 227.49334262014-0.0001363
227.493206320140

Note that this will affect other numeric output - such as that produced by writeascii and print - e.g.

chips> set_float_format("%.12f")
chips> print(23.0)
23.000000000000

Resetting "set_float_format("%f")" (the default) when you are finished may be useful.

For more information on the format specifier (e.g. "%.12f"), see "ahelp sprintf". There are also external webpages with more detailed information, such as the Association for Computing Machinery C Library Reference Guide.



Hardcopy (PDF): A4 | Letter
Last modified: 26 October 2007


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.