|
|
|
@ -1496,7 +1496,52 @@ char *ftostr12ns(const float &x)
|
|
|
|
|
return conv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert int to lj string with +123.0 format
|
|
|
|
|
// convert float to space-padded string with -_23.4_ format
|
|
|
|
|
char *ftostr32sp(const float &x) {
|
|
|
|
|
long xx = abs(x * 100);
|
|
|
|
|
uint8_t dig;
|
|
|
|
|
|
|
|
|
|
if (x < 0) { // negative val = -_0
|
|
|
|
|
conv[0] = '-';
|
|
|
|
|
dig = (xx / 1000) % 10;
|
|
|
|
|
conv[1] = dig ? '0' + dig : ' ';
|
|
|
|
|
}
|
|
|
|
|
else { // positive val = __0
|
|
|
|
|
dig = (xx / 10000) % 10;
|
|
|
|
|
if (dig) {
|
|
|
|
|
conv[0] = '0' + dig;
|
|
|
|
|
conv[1] = '0' + (xx / 1000) % 10;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
conv[0] = ' ';
|
|
|
|
|
dig = (xx / 1000) % 10;
|
|
|
|
|
conv[1] = dig ? '0' + dig : ' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conv[2] = '0' + (xx / 100) % 10; // lsd always
|
|
|
|
|
|
|
|
|
|
dig = xx % 10;
|
|
|
|
|
if (dig) { // 2 decimal places
|
|
|
|
|
conv[5] = '0' + dig;
|
|
|
|
|
conv[4] = '0' + (xx / 10) % 10;
|
|
|
|
|
conv[3] = '.';
|
|
|
|
|
}
|
|
|
|
|
else { // 1 or 0 decimal place
|
|
|
|
|
dig = (xx / 10) % 10;
|
|
|
|
|
if (dig) {
|
|
|
|
|
conv[4] = '0' + dig;
|
|
|
|
|
conv[3] = '.';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
conv[3] = conv[4] = ' ';
|
|
|
|
|
}
|
|
|
|
|
conv[5] = ' ';
|
|
|
|
|
}
|
|
|
|
|
conv[6] = '\0';
|
|
|
|
|
return conv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *itostr31(const int &xx)
|
|
|
|
|
{
|
|
|
|
|
conv[0]=(xx>=0)?'+':'-';
|
|
|
|
|