mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
lv_math: lv_math_num_to_str: return with buf
This commit is contained in:
parent
19f98ce8ea
commit
13351c0091
@ -37,14 +37,15 @@
|
||||
* Convert a number to string
|
||||
* @param num a number
|
||||
* @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements)
|
||||
* @return same as `buf` (just for convenience)
|
||||
*/
|
||||
void lv_math_num_to_str(int32_t num, char * buf)
|
||||
char * lv_math_num_to_str(int32_t num, char * buf)
|
||||
{
|
||||
char * buf_ori = buf;
|
||||
if(num == 0) {
|
||||
buf[0] = '0';
|
||||
buf[1] = '\0';
|
||||
return;
|
||||
return buf;
|
||||
} else if(num < 0) {
|
||||
(*buf) = '-';
|
||||
buf++;
|
||||
@ -85,6 +86,8 @@ void lv_math_num_to_str(int32_t num, char * buf)
|
||||
}
|
||||
|
||||
(*buf) = '\0';
|
||||
|
||||
return buf_ori;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -31,7 +31,13 @@ extern "C" {
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_math_num_to_str(int32_t num, char * buf);
|
||||
/**
|
||||
* Convert a number to string
|
||||
* @param num a number
|
||||
* @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements)
|
||||
* @return same as `buf` (just for convenience)
|
||||
*/
|
||||
char * lv_math_num_to_str(int32_t num, char * buf);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
Loading…
x
Reference in New Issue
Block a user