MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / root

Method root

src/Base/Unit.cpp:193–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193Unit Unit::root(const uint8_t num) const
194{
195 auto apply = [&](auto val) {
196 if (val % num != 0) {
197 throw UnitsMismatchError("unit values must be divisible by root");
198 }
199 return static_cast<decltype(val)>(val / num);
200 };
201
202 if (num < 1) {
203 throw UnitsMismatchError("root must be > 0");
204 }
205
206 UnitExponents res {};
207 std::transform(_exps.begin(), _exps.end(), res.begin(), apply);
208
209 return Unit {res};
210}
211
212Unit Unit::pow(const double exp) const
213{

Callers 2

readMethod · 0.45
TESTFunction · 0.45

Calls 3

transformFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected