num-bigint icon indicating copy to clipboard operation
num-bigint copied to clipboard

Set and multiply signs of a `BigInt`

Open virchau13 opened this issue 4 years ago • 1 comments

Currently, the only way to directly change the sign of a BigInt is to use.into_parts() and then BigInt::from_biguint(). It would be more convenient if we could directly set the sign, via a .set_sign() method or similar.

Especially for equations where terms of (-1)ⁿ are present, it would also be more convenient if there was a Mul<Sign> and MulAssign<Sign> impl so that one can e.g.

let minus_1_coef: Sign = Sign::Minus;
let answer: BigInt;
// ...
loop { 
    minus_1_coef = -minus_1_coef;
    answer *= minus_1_coef;
    // ...
}

virchau13 avatar Oct 27 '21 04:10 virchau13

Just wanted to ask if this feature is still considered? Or is it too complicated, takes too much time, goes against design etc?

Rot127 avatar Jun 02 '24 14:06 Rot127