fixed float printing errors
This commit is contained in:
@@ -68,6 +68,9 @@ char* toString_uint(uint64 n, bool withPostfix, bool uppercase){
|
||||
if(precision==0)\
|
||||
precision=toString_float_default_precision;\
|
||||
int cn=sprintf(str, "%.*f", precision, n);\
|
||||
/* remove trailing zeroes except .0*/\
|
||||
while(str[cn-1]=='0' && str[cn-2]!='.')\
|
||||
cn--;\
|
||||
if(withPostfix)\
|
||||
str[cn++]= uppercase ? 'F' : 'f';\
|
||||
str[cn]='\0';\
|
||||
|
||||
@@ -20,7 +20,14 @@ typedef union {
|
||||
float64 f64;
|
||||
void* ptr;
|
||||
} __kp_value_union;
|
||||
#define __kpVU(value) (__kp_value_union){ value }
|
||||
|
||||
|
||||
static inline __kp_value_union __kpVU_f(float64 f) { return (__kp_value_union){ .f64=f }; }
|
||||
inline __kp_value_union __kpVU_i(int64 f) { return (__kp_value_union){ .i64=f }; }
|
||||
|
||||
#define __kpVU_selectType(V) _Generic(V, float: __kpVU_f, double: __kpVU_f, default: __kpVU_i)(V)
|
||||
|
||||
#define __kpVU(V) __kpVU_selectType(V)
|
||||
|
||||
#define __kp_argsToFmts8(\
|
||||
a0, a1, a2, a3, a4, a5, a6, a7,...)\
|
||||
|
||||
Reference in New Issue
Block a user