|
@@ -1496,7 +1496,52 @@ char *ftostr12ns(const float &x)
|
1496
|
1496
|
return conv;
|
1497
|
1497
|
}
|
1498
|
1498
|
|
1499
|
|
-// Convert int to lj string with +123.0 format
|
|
1499
|
+// convert float to space-padded string with -_23.4_ format
|
|
1500
|
+char *ftostr32sp(const float &x) {
|
|
1501
|
+ long xx = abs(x * 100);
|
|
1502
|
+ uint8_t dig;
|
|
1503
|
+
|
|
1504
|
+ if (x < 0) { // negative val = -_0
|
|
1505
|
+ conv[0] = '-';
|
|
1506
|
+ dig = (xx / 1000) % 10;
|
|
1507
|
+ conv[1] = dig ? '0' + dig : ' ';
|
|
1508
|
+ }
|
|
1509
|
+ else { // positive val = __0
|
|
1510
|
+ dig = (xx / 10000) % 10;
|
|
1511
|
+ if (dig) {
|
|
1512
|
+ conv[0] = '0' + dig;
|
|
1513
|
+ conv[1] = '0' + (xx / 1000) % 10;
|
|
1514
|
+ }
|
|
1515
|
+ else {
|
|
1516
|
+ conv[0] = ' ';
|
|
1517
|
+ dig = (xx / 1000) % 10;
|
|
1518
|
+ conv[1] = dig ? '0' + dig : ' ';
|
|
1519
|
+ }
|
|
1520
|
+ }
|
|
1521
|
+
|
|
1522
|
+ conv[2] = '0' + (xx / 100) % 10; // lsd always
|
|
1523
|
+
|
|
1524
|
+ dig = xx % 10;
|
|
1525
|
+ if (dig) { // 2 decimal places
|
|
1526
|
+ conv[5] = '0' + dig;
|
|
1527
|
+ conv[4] = '0' + (xx / 10) % 10;
|
|
1528
|
+ conv[3] = '.';
|
|
1529
|
+ }
|
|
1530
|
+ else { // 1 or 0 decimal place
|
|
1531
|
+ dig = (xx / 10) % 10;
|
|
1532
|
+ if (dig) {
|
|
1533
|
+ conv[4] = '0' + dig;
|
|
1534
|
+ conv[3] = '.';
|
|
1535
|
+ }
|
|
1536
|
+ else {
|
|
1537
|
+ conv[3] = conv[4] = ' ';
|
|
1538
|
+ }
|
|
1539
|
+ conv[5] = ' ';
|
|
1540
|
+ }
|
|
1541
|
+ conv[6] = '\0';
|
|
1542
|
+ return conv;
|
|
1543
|
+}
|
|
1544
|
+
|
1500
|
1545
|
char *itostr31(const int &xx)
|
1501
|
1546
|
{
|
1502
|
1547
|
conv[0]=(xx>=0)?'+':'-';
|