MCPcopy Create free account
hub / github.com/davisking/dlib / shift_right

Method shift_right

dlib/bigint/bigint_kernel_2.cpp:1626–1660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1624// ----------------------------------------------------------------------------------------
1625
1626 void bigint_kernel_2::
1627 shift_right (
1628 const data_record* data,
1629 data_record* result
1630 ) const
1631 {
1632
1633 uint16* r = result->number; // result
1634 uint16* s = data->number; // source
1635 uint16* end = s + data->digits_used - 1;
1636
1637 while (s != end)
1638 {
1639 *r = (*s >> 1) | (*(s+1) << 15);
1640 ++r;
1641 ++s;
1642 }
1643 *r = *s >> 1;
1644
1645
1646 // calculate the new number for digits_used
1647 if (*r == 0)
1648 {
1649 if (data->digits_used != 1)
1650 result->digits_used = data->digits_used - 1;
1651 else
1652 result->digits_used = 1;
1653 }
1654 else
1655 {
1656 result->digits_used = data->digits_used;
1657 }
1658
1659
1660 }
1661
1662// ----------------------------------------------------------------------------------------
1663

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected