The following constants are format strings that can be used by the
various C scanf() or printf() functions to parse or
write sequences of characters corresponding to base LAL datatypes.
Since the C datatypes (short, int, long,
long long, float, double, etc.) do not have fixed
mappings to LAL base datatypes (INT2, INT4, INT8,
REAL4, REAL8, etc.), the appropriate format strings for
each LAL datatype must be determined at configuration time and set at
compile time.
These format strings give only the conversion character preceded by
any length modifier according to the type (short, long,
etc.). In particular they do not contain the initial
'%' character that initiates the conversion specification.
However, being #defined string literals, they can be combined
with "%" string literals or more complicated format strings
through implicit concatenation. Thus to scan string for a
UINT4 number n one would write:
sscanf( string, "%" LAL_UINT4_FORMAT, &n );Similarly, to print a
REAL8 number x with 12 digits
following the decimal place, one could use the following:
printf( "%.12" LAL_REAL8_FORMAT, x );Of course, floating-point numbers are more commonly printed using the
"%e" conversion specifier, which does not generally require
type-dependent length modifiers.
| Name | Usual value |
| LAL_INT2_FORMAT | "hd" |
| LAL_INT4_FORMAT | "d" or "ld" |
| LAL_INT8_FORMAT | "ld" or "lld" |
| LAL_UINT2_FORMAT | "hu" |
| LAL_UINT4_FORMAT | "u" or "lu" |
| LAL_UINT8_FORMAT | "lu" or "llu" |
| LAL_REAL4_FORMAT | "f" |
| LAL_REAL8_FORMAT | "lf" |