##
Formatting Axis Values

The coordinate values associated with each axis of a FrameFrame are stored (e.g. within your program) as double values. The Frame class therefore provides a function, astFormatastFormat, to convert these values into formatted strings for display:

108#108

Here, the astFormat function is passed a Frame pointer, the number of an axis (“iaxis”) and a double precision value to format (“value”). It returns a pointer to character string containing the formatted value.

By default, the formatting applied will be determined by the Frame's Digits attribute and will normally display results with seven digits of precision (corresponding approximately to the C “float” data type on many machines). Setting a different Digits value, however, allows you to adjust the precision as necessary to suit the accuracy of the coordinate data you are processing. If finer control is needed, it is also possible to set a Digits value for each individual axis by appending an axis number to the attribute name (e.g. “Digits(2)”). If this is done, it over-rides the effect of the Frame's main Digits value for that axis.

Even finer control is possible by setting the (character string) Format attribute for a Frame axis. The string given should contain a C format specifier which explicitly determines how the values on that axis should be formatted. This will over-ride the effects of any Digits value. Any valid “printf” format specifier may be used so long as it consumes exactly one double value.

When setting Format values, remember that the “%” which appears in the format specifier may need to be doubled to “%%” if you are using a function (such as astSetastSet) which interprets “printf” format specifiers itself.

It is recommended that you use astFormat whenever you display formatted coordinate values, even although you could format them yourself using “sprintf”. This is because it puts the Frame in control of formatting. When you start to handle more elaborate Frames (representing, say, celestial coordinates), you will need different formatting methods. This approach delivers them without any change to your software.

You should also consider regularly using the astNormastNorm function, described below (§7.7), for any values that will be made visible to the user of your software.