Integers, money and times as text, without printf.
More...
|
| char * | fmtInt (char *p, int32_t v) |
| | Write an integer: "-123".
|
| |
| char * | fmtMoney (char *p, int32_t v) |
| | Write an amount of money: "$1234", "-$5".
|
| |
| char * | fmtCash (char *p, int32_t v) |
| | Write money with thousands separators: "$1,234".
|
| |
| char * | fmtShort (char *p, int32_t v) |
| | Write money short for a narrow space: as fmtMoney(), but "$12K" from $10,000.
|
| |
| char * | fmtTime (char *p, uint16_t secs) |
| | Write a time as minutes and seconds: "1:05".
|
| |
| char * | fmtStr (char *p, const char *s) |
| | Copy a string.
|
| |
Integers, money and times as text, without printf.
Each call writes at p, terminates the string and returns the new end, so calls chain:
char buf[16], *p = buf;
char * fmtStr(char *p, const char *s)
Copy a string.
char * fmtMoney(char *p, int32_t v)
Write an amount of money: "$1234", "-$5".
The caller's buffer must be big enough: 12 characters hold any int32_t.
◆ fmtInt()
| char * fmtInt |
( |
char * |
p, |
|
|
int32_t |
v |
|
) |
| |
Write an integer: "-123".
- Parameters
-
| p | Where to write. |
| v | The number. |
- Returns
- The end of the string (at its terminating 0).
◆ fmtMoney()
| char * fmtMoney |
( |
char * |
p, |
|
|
int32_t |
v |
|
) |
| |
Write an amount of money: "$1234", "-$5".
- Parameters
-
| p | Where to write. |
| v | Dollars. |
- Returns
- The end of the string.
◆ fmtCash()
| char * fmtCash |
( |
char * |
p, |
|
|
int32_t |
v |
|
) |
| |
Write money with thousands separators: "$1,234".
- Parameters
-
| p | Where to write. |
| v | Dollars. |
- Returns
- The end of the string.
◆ fmtShort()
| char * fmtShort |
( |
char * |
p, |
|
|
int32_t |
v |
|
) |
| |
Write money short for a narrow space: as fmtMoney(), but "$12K" from $10,000.
From 10,000 on (either sign) it writes whole thousands, rounded toward zero: 12,999 is "$12K".
- Parameters
-
| p | Where to write. |
| v | Dollars. |
- Returns
- The end of the string.
◆ fmtTime()
| char * fmtTime |
( |
char * |
p, |
|
|
uint16_t |
secs |
|
) |
| |
Write a time as minutes and seconds: "1:05".
- Parameters
-
| p | Where to write. |
| secs | Seconds. |
- Returns
- The end of the string.
◆ fmtStr()
| char * fmtStr |
( |
char * |
p, |
|
|
const char * |
s |
|
) |
| |
Copy a string.
- Parameters
-
| p | Where to write. |
| s | The string. |
- Returns
- The end of the copy.