Merge branch 'master' of github.com:pantor/inja
diff --git a/include/inja/renderer.hpp b/include/inja/renderer.hpp
index cd49082..54e7322 100644
--- a/include/inja/renderer.hpp
+++ b/include/inja/renderer.hpp
@@ -437,7 +437,11 @@
const auto args = get_arguments<2>(node);
const int precision = args[1]->get<int>();
const double result = std::round(args[0]->get<double>() * std::pow(10.0, precision)) / std::pow(10.0, precision);
- result_ptr = std::make_shared<json>(std::move(result));
+ if(0==precision){
+ result_ptr = std::make_shared<json>(int(result));
+ }else{
+ result_ptr = std::make_shared<json>(std::move(result));
+ }
json_tmp_stack.push_back(result_ptr);
json_eval_stack.push(result_ptr.get());
} break;
diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp
index cebda1f..a19efe9 100644
--- a/single_include/inja/inja.hpp
+++ b/single_include/inja/inja.hpp
@@ -3933,7 +3933,11 @@
const auto args = get_arguments<2>(node);
const int precision = args[1]->get<int>();
const double result = std::round(args[0]->get<double>() * std::pow(10.0, precision)) / std::pow(10.0, precision);
- result_ptr = std::make_shared<json>(std::move(result));
+ if(0==precision){
+ result_ptr = std::make_shared<json>(int(result));
+ }else{
+ result_ptr = std::make_shared<json>(std::move(result));
+ }
json_tmp_stack.push_back(result_ptr);
json_eval_stack.push(result_ptr.get());
} break;
diff --git a/test/test-functions.cpp b/test/test-functions.cpp
index 4ec4c25..dab8e9b 100644
--- a/test/test-functions.cpp
+++ b/test/test-functions.cpp
@@ -88,7 +88,7 @@
}
SUBCASE("round") {
- CHECK(env.render("{{ round(4, 0) }}", data) == "4.0");
+ CHECK(env.render("{{ round(4, 0) }}", data) == "4");
CHECK(env.render("{{ round(temperature, 2) }}", data) == "25.68");
// CHECK_THROWS_WITH( env.render("{{ round(name, 2) }}", data), "[inja.exception.json_error]
// [json.exception.type_error.302] type must be number, but is string" );