mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 07:49:03 +08:00
Fix to_string_nozero formatter when rounded without any '.'.
supermerill/SuperSlicer#2172
This commit is contained in:
parent
65288d3b49
commit
0c92076a14
@ -35,16 +35,18 @@ std::string to_string_nozero(double value, int32_t max_precision) {
|
|||||||
ss << std::fixed << std::setprecision(int(std::min(15 - long10, int(max_precision)))) << value;
|
ss << std::fixed << std::setprecision(int(std::min(15 - long10, int(max_precision)))) << value;
|
||||||
std::string ret = ss.str();
|
std::string ret = ss.str();
|
||||||
uint8_t nb_del = 0;
|
uint8_t nb_del = 0;
|
||||||
uint8_t idx_char;
|
if (ret.find('.') != std::string::npos) {
|
||||||
for (idx_char = uint8_t(ss.tellp()) - 1; idx_char > 0; idx_char--) {
|
uint8_t idx_char;
|
||||||
if (ret[idx_char] == '0')
|
for (idx_char = uint8_t(ss.tellp()) - 1; idx_char > 0; idx_char--) {
|
||||||
|
if (ret[idx_char] == '0')
|
||||||
|
nb_del++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// remove the '.' at the end of the int
|
||||||
|
if (idx_char > 0 && ret[idx_char] == '.')
|
||||||
nb_del++;
|
nb_del++;
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
// remove the '.' at the end of the int
|
|
||||||
if(idx_char > 0 && ret[idx_char] == '.')
|
|
||||||
nb_del++;
|
|
||||||
|
|
||||||
if (nb_del > 0)
|
if (nb_del > 0)
|
||||||
return ret.substr(0, ret.size() - nb_del);
|
return ret.substr(0, ret.size() - nb_del);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user