fix: don't warn when rounding by less than 1 micro-inch#597
fix: don't warn when rounding by less than 1 micro-inch#597eyal0 merged 5 commits intopcb2gcode:masterfrom
Conversation
| }); | ||
| if (best_available_drill->difference(wanted_length, inputFactor)) { | ||
|
|
||
| auto difference = best_available_drill->difference(wanted_length, inputFactor); |
There was a problem hiding this comment.
I prefer const auto if you don't mind. That way I don't have to later wonder about whether or not it might change.
There was a problem hiding this comment.
Makes sense, thanks.
| cerr << "Info: bit " << wanted_drill.first << " (" | ||
| << old_string << ") is rounded to " | ||
| << drill_to_string(wanted_drill_bit) << std::endl; | ||
| if (difference > 1e-6 || difference < -1e-6) { |
There was a problem hiding this comment.
Or abs(difference) > 1e-6. That way you don't have to repeat the constant.
Another way that we could do this PR is to string compare old_string with drill_to_string(wanted_drill_bit). But your way seems better, yes.
There was a problem hiding this comment.
Using abs() was my initial approach, but then the compiler started shouting at me:
drill.cpp:855:35: error: no matching function for call to ‘abs(const boost::optional<double>&)’
if (abs(difference) > 1e-6) {
^
[long list of "no known conversion for argument 1 from ‘const boost::optional<double>’ to '[other format]']
There was a problem hiding this comment.
I didn't even realize that it's an optional! Huh.
So you'll need if (difference && abs(*difference) > 1e-6)
Sorry about that! I must've had a good reason why it's optional but I forgot. Maybe because you might have units that can't be subtracted together or something.
as it won't be touched afterwards.
| wanted_drill_bit.diameter = best_available_drill->diameter().asInch(inputFactor); | ||
| wanted_drill_bit.unit = "inch"; | ||
| if (difference > 1e-6 || difference < -1e-6) { | ||
| if (difference && abs(*difference) > 1e-6) { |
There was a problem hiding this comment.
Oh man I'm so sorry to do this to you, I reviewed it on my phone and I didn't see that there is already if(difference) above! I'm a dummy.
So no need to test for difference. Doh!
There was a problem hiding this comment.
I was wondering about that, but then I don't know a lot about C++/boost :)
fixed in e8d68de
as it's checked a few lines above anyway
accidentally commited an experimental change
When working in metric units,
pcb2gcodeis giving warnings likeWith this patch, warnings are only printed when the amount of rounding was more than 1 micro-inch.