Skip to content

Commit

Permalink
rename popcount
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Jul 26, 2023
1 parent f112791 commit dfa9cf3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/standard/BigInteger.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -2880,8 +2880,22 @@ module BigInteger {
proc bigint.lucnum2(ref fnsub1: bigint, n: integral)
do BigInteger.lucNum2(this, fnsub1, n);

// Bit operations
proc bigint.popcount() : uint {
@deprecated("popcount is deprecated - please use :proc:`bigint.popCount` instead")
proc bigint.popcount() : uint do return this.popCount();

/*
Returns the number of ``1`` bits in ``this``. If ``this`` is negative, the
number of ``1`` bits is infinite and the return value is the largest
possible :type:`~GMP.mp_bitcnt_t`.
:returns: The number of ``1`` bits in ``this``
:rtype: ``uint``
.. seealso::
:proc:`GMP.mpz_popcount` and
`mpz_popcount <https://gmplib.org/manual/Integer-Logic-and-Bit-Fiddling>`_.
*/
proc bigint.popCount() : uint {
const t_ = this.localize();
var ret: c_ulong;

Expand Down
8 changes: 8 additions & 0 deletions test/deprecated/BigInteger/popcount.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// deprecated in 1.32 by Jade
use BigInteger;

var a: bigint = 0b010101010101;
var n: uint;

n = a.popcount();
writeln(n);
2 changes: 2 additions & 0 deletions test/deprecated/BigInteger/popcount.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
popcount.chpl:7: warning: popcount is deprecated - please use bigint.popCount instead
6

0 comments on commit dfa9cf3

Please sign in to comment.