| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To display numeric values on the screen, or convert them to strings, it is
often convenient to use the standard printf, fprintf, or
sprintf functions. Each of these functions requires you to specify the
data type as part of the “format” string (for example, to display an
int, you might write printf("%d", x), but to display a long
int, you might write printf("%ld", x)).
The macros listed below can be used to display WFDB_Sample,
WFDB_Time, WFDB_Frequency, and WFDB_Gain values,
regardless of which standard C data types these represent. Using these macros
can help to ensure your program is portable to other operating systems and C
compilers.
Each macro expands to a string constant (such as "d" or "ld"),
which does not include the leading ‘%’ character. For example, to display
a table of time and sample values, we might write:
WFDB_Time t = 0;
WFDB_Sample v[2];
while (getvec(v) > 0) {
printf("%10"WFDB_Pd_TIME" %6"WFDB_Pd_SAMP" %6"WFDB_Pd_SAMP"\n",
t, v[0], v[1]);
t++;
}
|
The following macros are defined in ‘<wfdb/wfdb.h>’:
| Macro | Argument type | Format | Example output |
|---|---|---|---|
| WFDB_Pd_SAMP | WFDB_Sample | Base 10 | ‘995’ |
| WFDB_Pi_SAMP | WFDB_Sample | Base 10 | ‘995’ |
| WFDB_Po_SAMP | WFDB_Sample | Unsigned base 8 | ‘1743’ |
| WFDB_Pu_SAMP | WFDB_Sample | Unsigned base 10 | ‘995’ |
| WFDB_Px_SAMP | WFDB_Sample | Unsigned base 16 | ‘3e3’ |
| WFDB_PX_SAMP | WFDB_Sample | Unsigned base 16 | ‘3E3’ |
| WFDB_Pd_TIME | WFDB_Time | Base 10 | ‘650000’ |
| WFDB_Pi_TIME | WFDB_Time | Base 10 | ‘650000’ |
| WFDB_Po_TIME | WFDB_Time | Unsigned base 8 | ‘2365420’ |
| WFDB_Pu_TIME | WFDB_Time | Unsigned base 10 | ‘650000’ |
| WFDB_Px_TIME | WFDB_Time | Unsigned base 16 | ‘9eb10’ |
| WFDB_PX_TIME | WFDB_Time | Unsigned base 16 | ‘9EB10’ |
| WFDB_Pe_FREQ | WFDB_Frequency | Exponential | ‘3.600000e+02’ |
| WFDB_PE_FREQ | WFDB_Frequency | Exponential | ‘3.600000E+02’ |
| WFDB_Pf_FREQ | WFDB_Frequency | Fixed-point | ‘360.000000’ |
| WFDB_Pg_FREQ | WFDB_Frequency | Automatic | ‘360’ |
| WFDB_PG_FREQ | WFDB_Frequency | Automatic | ‘360’ |
| WFDB_Pe_GAIN | WFDB_Gain | Exponential | ‘2.000000e+02’ |
| WFDB_PE_GAIN | WFDB_Gain | Exponential | ‘2.000000E+02’ |
| WFDB_Pf_GAIN | WFDB_Gain | Fixed-point | ‘200.000000’ |
| WFDB_Pg_GAIN | WFDB_Gain | Automatic | ‘200’ |
| WFDB_PG_GAIN | WFDB_Gain | Automatic | ‘200’ |
(The ‘d’ and ‘i’ formats are equivalent, and are provided for
symmetry with scanf. For more information, see the documentation of
your C compiler.)
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
PhysioNet (wfdb@physionet.org)