Skip to content

Commit 041f259

Browse files
Merge pull request #84 from cydanil/fix/mach_conversion
Use explicit Mach to meter/second conversion factor
2 parents c4f908a + b056313 commit 041f259

12 files changed

+68
-65
lines changed

src/Core/Utils.vala

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ namespace Pebbles {
3131

3232
public static string format_result (string result) {
3333
string output = result.replace (".", Utils.get_local_radix_symbol ());
34+
if (!result.contains(Utils.get_local_radix_symbol ())) {
35+
output += Utils.get_local_radix_symbol () + "0";
36+
}
3437

3538
// Remove trailing 0s and decimals
3639
while (output.has_suffix ("0")) {
@@ -546,37 +549,37 @@ namespace Pebbles {
546549
string output = "";
547550
switch (accuracy) {
548551
case 10:
549-
output = ("%.10f".printf (result));
552+
output = ("%.10lf".printf (result));
550553
break;
551554
case 9:
552-
output = ("%.9f".printf (result));
555+
output = ("%.9lf".printf (result));
553556
break;
554557
case 8:
555-
output = ("%.8f".printf (result));
558+
output = ("%.8lf".printf (result));
556559
break;
557560
case 7:
558-
output = ("%.7f".printf (result));
561+
output = ("%.7lf".printf (result));
559562
break;
560563
case 6:
561-
output = ("%.6f".printf (result));
564+
output = ("%.6lf".printf (result));
562565
break;
563566
case 5:
564-
output = ("%.5f".printf (result));
567+
output = ("%.5lf".printf (result));
565568
break;
566569
case 4:
567-
output = ("%.4f".printf (result));
570+
output = ("%.4lf".printf (result));
568571
break;
569572
case 3:
570-
output = ("%.3f".printf (result));
573+
output = ("%.3lf".printf (result));
571574
break;
572575
case 2:
573-
output = ("%.2f".printf (result));
576+
output = ("%.2lf".printf (result));
574577
break;
575578
case 1:
576-
output = ("%.1f".printf (result));
579+
output = ("%.1lf".printf (result));
577580
break;
578581
case 0:
579-
output = ("%.0f".printf (result));
582+
output = ((int) result).to_string();
580583
break;
581584
default:
582585
output = result.to_string ();

src/Views/ConvAngleView.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ namespace Pebbles {
3535
bool ctrl_held = false;
3636

3737
private const double[] unit_multipliers = {
38-
1,
39-
(Math.PI/180),
38+
1.0,
39+
(Math.PI/180.0),
4040
(1.111111111),
41-
((Math.PI * 1000)/180),
42-
3600,
43-
60,
41+
((Math.PI * 1000.0)/180.0),
42+
3600.0,
43+
60.0,
4444
};
4545

4646
private string[] units = {

src/Views/ConvAreaView.vala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ namespace Pebbles {
3535
bool ctrl_held = false;
3636

3737
private const double[] unit_multipliers = {
38-
1000000, // Sqaure millimetre
39-
10000, // Square centimetre
40-
1, // Square metre
38+
1000000.0, // Sqaure millimetre
39+
10000.0, // Square centimetre
40+
1.0, // Square metre
4141
0.000001, // Square kilometre
42-
1550, // Square inch
42+
1550.0, // Square inch
4343
10.7639, // Square foot
4444
1.19599, // Square yard
4545
0.0001, // Hectare

src/Views/ConvDataView.vala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ namespace Pebbles {
4141
8,
4242
7.62939,
4343
0.008,
44-
(1/134.218),
45-
(1/125000),
46-
(1/137438.953),
47-
(1/125000000),
48-
(1/140700000),
49-
1000000,
50-
1000,
44+
1.0/134.218,
45+
1.0/125000.0,
46+
1.0/137438.953,
47+
1.0/125000000.0,
48+
1.0/140700000.0,
49+
1000000.0,
50+
1000.0,
5151
976.563,
52-
1,
53-
(1/1.049),
52+
1.0,
53+
1.0/1.049,
5454
0.001,
55-
(1/1073.742),
55+
1/1073.742,
5656
0.000001,
57-
(1/1100000),
57+
1.0/1100000.0,
5858
0.000000001,
59-
(1/1126000000),
59+
1.0/1126000000.0,
6060
};
6161

6262
private string[] units = {

src/Views/ConvEnergyView.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ namespace Pebbles {
3535
bool ctrl_held = false;
3636

3737
private const double[] unit_multipliers = {
38-
1,
38+
1.0,
3939
0.001,
4040
0.239006,
4141
0.000239006,
42-
(1 / 3600),
42+
1.0 / 3600.0,
4343
0.000000278,
4444
//6242000000000000000, Future Support
4545
0.000947817,
46-
(1 / 105500000),
46+
1.0 / 105500000.0,
4747
0.737562,
4848
};
4949

src/Views/ConvLengthView.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ namespace Pebbles {
3434
bool ctrl_held = false;
3535

3636
private const double[] unit_multipliers = {
37-
1000000000, // Nano
38-
1000000, // Micron
39-
1000, // Milli
40-
100, // Centi
41-
1, // Metre
37+
1000000000.0, // Nano
38+
1000000.0, // Micron
39+
1000.0, // Milli
40+
100.0, // Centi
41+
1.0, // Metre
4242
0.001, // Kilo
4343
39.3701, // Inch
4444
3.28084, // Foot

src/Views/ConvMassView.vala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ namespace Pebbles {
3535
bool ctrl_held = false;
3636

3737
private const double[] unit_multipliers = {
38-
1000000,
39-
1000,
40-
1,
38+
1000000.0,
39+
1000.0,
40+
1.0,
4141
0.001,
4242
0.000001,
43-
(1 / 907184.74),
44-
(1 / 1016000),
45-
(1 / 28.35),
46-
(1 / 453.592),
47-
(1 / 6350.293),
43+
(1.0 / 907184.74),
44+
1.0 / 1016000.0,
45+
(1.0 / 28.35),
46+
(1.0 / 453.592),
47+
(1.0 / 6350.293),
4848
};
4949

5050
private string[] units = {

src/Views/ConvPowerView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Pebbles {
3535
bool ctrl_held = false;
3636

3737
private const double[] unit_multipliers = {
38-
1,
38+
1.0,
3939
0.001,
4040
0.00135962,
4141
0.00134102,

src/Views/ConvPressView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Pebbles {
3838
0.000009869,
3939
0.00001,
4040
0.00750062,
41-
1,
41+
1.0,
4242
0.000145038,
4343
0.00750062,
4444
};

src/Views/ConvSpeedView.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ namespace Pebbles {
3535
bool ctrl_held = false;
3636

3737
private const double[] unit_multipliers = {
38-
100,
39-
1,
38+
100.0,
39+
1.0,
4040
3.6,
4141
3.28084,
4242
2.23694,
4343
1.94384,
44-
(1/343),
44+
1.0/343.0,
4545
};
4646

4747
private string[] units = {

0 commit comments

Comments
 (0)