Skip to content

Commit

Permalink
Merge pull request #84 from cydanil/fix/mach_conversion
Browse files Browse the repository at this point in the history
Use explicit Mach to meter/second conversion factor
  • Loading branch information
SubhadeepJasu authored Sep 13, 2021
2 parents c4f908a + b056313 commit 041f259
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 65 deletions.
25 changes: 14 additions & 11 deletions src/Core/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ namespace Pebbles {

public static string format_result (string result) {
string output = result.replace (".", Utils.get_local_radix_symbol ());
if (!result.contains(Utils.get_local_radix_symbol ())) {
output += Utils.get_local_radix_symbol () + "0";
}

// Remove trailing 0s and decimals
while (output.has_suffix ("0")) {
Expand Down Expand Up @@ -546,37 +549,37 @@ namespace Pebbles {
string output = "";
switch (accuracy) {
case 10:
output = ("%.10f".printf (result));
output = ("%.10lf".printf (result));
break;
case 9:
output = ("%.9f".printf (result));
output = ("%.9lf".printf (result));
break;
case 8:
output = ("%.8f".printf (result));
output = ("%.8lf".printf (result));
break;
case 7:
output = ("%.7f".printf (result));
output = ("%.7lf".printf (result));
break;
case 6:
output = ("%.6f".printf (result));
output = ("%.6lf".printf (result));
break;
case 5:
output = ("%.5f".printf (result));
output = ("%.5lf".printf (result));
break;
case 4:
output = ("%.4f".printf (result));
output = ("%.4lf".printf (result));
break;
case 3:
output = ("%.3f".printf (result));
output = ("%.3lf".printf (result));
break;
case 2:
output = ("%.2f".printf (result));
output = ("%.2lf".printf (result));
break;
case 1:
output = ("%.1f".printf (result));
output = ("%.1lf".printf (result));
break;
case 0:
output = ("%.0f".printf (result));
output = ((int) result).to_string();
break;
default:
output = result.to_string ();
Expand Down
10 changes: 5 additions & 5 deletions src/Views/ConvAngleView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
1,
(Math.PI/180),
1.0,
(Math.PI/180.0),
(1.111111111),
((Math.PI * 1000)/180),
3600,
60,
((Math.PI * 1000.0)/180.0),
3600.0,
60.0,
};

private string[] units = {
Expand Down
8 changes: 4 additions & 4 deletions src/Views/ConvAreaView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
1000000, // Sqaure millimetre
10000, // Square centimetre
1, // Square metre
1000000.0, // Sqaure millimetre
10000.0, // Square centimetre
1.0, // Square metre
0.000001, // Square kilometre
1550, // Square inch
1550.0, // Square inch
10.7639, // Square foot
1.19599, // Square yard
0.0001, // Hectare
Expand Down
24 changes: 12 additions & 12 deletions src/Views/ConvDataView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ namespace Pebbles {
8,
7.62939,
0.008,
(1/134.218),
(1/125000),
(1/137438.953),
(1/125000000),
(1/140700000),
1000000,
1000,
1.0/134.218,
1.0/125000.0,
1.0/137438.953,
1.0/125000000.0,
1.0/140700000.0,
1000000.0,
1000.0,
976.563,
1,
(1/1.049),
1.0,
1.0/1.049,
0.001,
(1/1073.742),
1/1073.742,
0.000001,
(1/1100000),
1.0/1100000.0,
0.000000001,
(1/1126000000),
1.0/1126000000.0,
};

private string[] units = {
Expand Down
6 changes: 3 additions & 3 deletions src/Views/ConvEnergyView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
1,
1.0,
0.001,
0.239006,
0.000239006,
(1 / 3600),
1.0 / 3600.0,
0.000000278,
//6242000000000000000, Future Support
0.000947817,
(1 / 105500000),
1.0 / 105500000.0,
0.737562,
};

Expand Down
10 changes: 5 additions & 5 deletions src/Views/ConvLengthView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
1000000000, // Nano
1000000, // Micron
1000, // Milli
100, // Centi
1, // Metre
1000000000.0, // Nano
1000000.0, // Micron
1000.0, // Milli
100.0, // Centi
1.0, // Metre
0.001, // Kilo
39.3701, // Inch
3.28084, // Foot
Expand Down
16 changes: 8 additions & 8 deletions src/Views/ConvMassView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
1000000,
1000,
1,
1000000.0,
1000.0,
1.0,
0.001,
0.000001,
(1 / 907184.74),
(1 / 1016000),
(1 / 28.35),
(1 / 453.592),
(1 / 6350.293),
(1.0 / 907184.74),
1.0 / 1016000.0,
(1.0 / 28.35),
(1.0 / 453.592),
(1.0 / 6350.293),
};

private string[] units = {
Expand Down
2 changes: 1 addition & 1 deletion src/Views/ConvPowerView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
1,
1.0,
0.001,
0.00135962,
0.00134102,
Expand Down
2 changes: 1 addition & 1 deletion src/Views/ConvPressView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Pebbles {
0.000009869,
0.00001,
0.00750062,
1,
1.0,
0.000145038,
0.00750062,
};
Expand Down
6 changes: 3 additions & 3 deletions src/Views/ConvSpeedView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
100,
1,
100.0,
1.0,
3.6,
3.28084,
2.23694,
1.94384,
(1/343),
1.0/343.0,
};

private string[] units = {
Expand Down
10 changes: 5 additions & 5 deletions src/Views/ConvTimeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace Pebbles {
bool ctrl_held = false;

private const double[] unit_multipliers = {
3600000000,
3600000,
3600,
60,
1,
3600000000.0,
3600000.0,
3600.0,
60.0,
1.0,
0.0416667,
0.00595238,
0.00136986,
Expand Down
14 changes: 7 additions & 7 deletions src/Views/ConvVolumeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ namespace Pebbles {
};

private const double[] multipliers = {
1000000,
1000000,
1000,
1,
202884,
67628,
33814,
1000000.0,
1000000.0,
1000.0,
1.0,
202884.0,
67628.0,
33814.0,
4166.667,
2113.376,
1056.688,
Expand Down

0 comments on commit 041f259

Please sign in to comment.