Robbepop / apint

Arbitrary precision integers library.
Other
27 stars 4 forks source link

Implement methods to check for additive neutral and multiplicative neutral elements #6

Closed Robbepop closed 6 years ago

Robbepop commented 6 years ago

Users of ApInt may often have the need to check an ApInt instance for additive or multiplicative neutral elements. Currently users would need to create an ApInt with an equivalent bit width representing either 1 or 0 and compare it to their instance. This may be inefficient.

Adding ApInt::is_zero and ApInt::is_one allows for efficient alternatives in these situations.

Robbepop commented 6 years ago

Implemented in https://github.com/Robbepop/apint/commit/365795a72ab8f437e0fd0f540b25ef8b7ccc91a5.