Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FormerLurker/ArcWelderLib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFormerLurker <hochgebe@gmail.com>2020-11-16 18:00:56 +0300
committerFormerLurker <hochgebe@gmail.com>2020-11-16 18:00:56 +0300
commit0f57a03f82a555a9b6d3afdfb133457c72455d54 (patch)
treeb5403a38d5ecd473f727b34e48099c9e35ba320c /GcodeProcessorLib/utilities.cpp
parentb995df6e38d0185f32f06cac87e781249975b738 (diff)
Add the job guid to the py arguments and progress updates. Add additional progress data.
Diffstat (limited to 'GcodeProcessorLib/utilities.cpp')
-rw-r--r--GcodeProcessorLib/utilities.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/GcodeProcessorLib/utilities.cpp b/GcodeProcessorLib/utilities.cpp
index d126755..6ff083f 100644
--- a/GcodeProcessorLib/utilities.cpp
+++ b/GcodeProcessorLib/utilities.cpp
@@ -229,6 +229,15 @@ std::string utilities::center(std::string input, int width)
return std::string(left_padding, ' ') + input + std::string(right_padding, ' ');
}
+double utilities::get_percent_change(int v1, int v2)
+{
+ if (v1 != 0)
+ {
+ return (((double)v2 - (double)v1) / (double)v1) * 100.0;
+ }
+ return 0;
+}
+
std::string utilities::get_percent_change_string(int v1, int v2, int precision)
{
std::stringstream format_stream;
@@ -247,7 +256,7 @@ std::string utilities::get_percent_change_string(int v1, int v2, int precision)
}
else
{
- double percent_change = (((double)v2 - (double)v1) / (double)v1) * 100.0;
+ double percent_change = get_percent_change(v1, v2);
format_stream << std::fixed << std::setprecision(precision) << percent_change << "%";
}
return format_stream.str();