19389, "lydia-duncan", "BigInteger module: should we rename the scan0 and scan1 methods?", "2022-03-08T23:26:20Z"
These methods inherited their names from the GMP functions, mpz_scan0 and mpz_scan1. Their description there says:
Scan op, starting from bit starting_bit, towards more significant bits, until the first 0 or 1 bit (respectively) is found. Return the index of the found bit.
If the bit at starting_bit is already what’s sought, then starting_bit is returned.
If there’s no bit found, then the largest possible mp_bitcnt_t is returned. This will happen in mpz_scan0 past the end of a negative number, or mpz_scan1 past the end of a nonnegative number.
Offline, Brad suggested that maybe scanFor0 or scanFor0Bit or something along those lines would be clearer (with a preference for scanFor0).
Outside context:
The Python library GMPY ended up switching their names to bit_scan0 and bit_scan1 with GMPY2, to avoid conflicts with the inclusion of other multi-precision libraries. The original names were scan0 and scan1. This did result in some frustration, but the frustration was alleviated by being able to rename back to the old names on import.
The Multiple Precision Integers and Rationals Library (MPIR) also uses mpz_scan0 and mpz_scan1 as the names for these functions
Julia uses scan0 and scan1 in the Bits package.
PHP turned up in a simple search of the names with gmp_scan0 and gmp_scan1, though I don't think we necessarily want to follow PHP's lead.
I found a few BigInteger-like libraries for Swift, but had difficulty finding scan0 in them. They seemed to provide a subset of the functionality so maybe just omitted these