MCPcopy Create free account
hub / github.com/LUX-Core/lux / DivideFourWordsByTwo

Function DivideFourWordsByTwo

src/cryptopp/integer.cpp:457–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455// do a 4 word by 2 word divide, returns 2 word quotient in Q0 and Q1
456template <class S, class D>
457inline D DivideFourWordsByTwo(S *T, const D &Al, const D &Ah, const D &B)
458{
459 // Profiling tells us the original second case was dominant, so it was promoted to the first If statement.
460 // The code change occurred at Commit dc99266599a0e72d.
461
462 if (!!B)
463 {
464 S Q[2];
465 T[0] = Al.GetLowHalf();
466 T[1] = Al.GetHighHalf();
467 T[2] = Ah.GetLowHalf();
468 T[3] = Ah.GetHighHalf();
469 Q[1] = DivideThreeWordsByTwo<S, D>(T+1, B.GetLowHalf(), B.GetHighHalf());
470 Q[0] = DivideThreeWordsByTwo<S, D>(T, B.GetLowHalf(), B.GetHighHalf());
471 return D(Q[0], Q[1]);
472 }
473 else // if divisor is 0, we assume divisor==2**(2*WORD_BITS)
474 {
475 return D(Ah.GetLowHalf(), Ah.GetHighHalf());
476 }
477}
478
479// returns quotient, which must fit in a word
480inline word DWord::operator/(word a)

Callers

nothing calls this directly

Calls 2

GetLowHalfMethod · 0.80
GetHighHalfMethod · 0.80

Tested by

no test coverage detected