New Issue: [Library Stabilization] Should these BigInteger methods return booleans?

17701, "lydia-duncan", "[Library Stabilization] Should these BigInteger methods return booleans?", "2021-05-12T21:12:45Z"

There are a number of methods on the bigint type that return 0 or some other value. It seems to me like these methods are a result of booleans being in a weird state for C where they can be used but aren't necessarily used extensively when they could be. In Chapel, it seems more appropriate to return a bool where possible.

Affected methods:

  • bigint.divisible_p()
  • bigint.divisible_2exp_p()
  • bigint.perfect_power_p()
  • bigint.perfect_square_p()
  • bigint.congruent_p()
  • bigint.congruent_2exp_p()
  • bigint.even_p()
  • bigint.odd_p()

I would probably rename these functions to something like isDivisible or isDivisibleBy, etc. while there, and drop the p (I have no idea why they end in p - maybe it stands for precision?)

Some of these at first glance seem like they would make sense to return something other than a bool, but seem to only return 0 or 1 today, so I think using them in this manner is appropriate (and there's probably something that can be done to ensure they always return the "right" bool value even if the underlying implementation changes (which seems unlikely at this point but is something to watch out for).