@@ -60,7 +60,7 @@ public class BigInteger: IComparable, IConvertible, IEquatable<BigInteger>
60
60
/// </remarks>
61
61
private readonly uint [ ] _data ;
62
62
63
- private static readonly BigInteger _zero = new BigInteger ( 0 , new uint [ ] { } ) ;
63
+ private static readonly BigInteger _zero = new BigInteger ( 0 , Array . Empty < uint > ( ) ) ;
64
64
private static readonly BigInteger _one = new BigInteger ( 1 , new uint [ ] { 1 } ) ;
65
65
private static readonly BigInteger _two = new BigInteger ( 1 , new uint [ ] { 2 } ) ;
66
66
private static readonly BigInteger _five = new BigInteger ( 1 , new uint [ ] { 5 } ) ;
@@ -472,7 +472,7 @@ public string ToString(uint radix)
472
472
StringBuilder sb = new StringBuilder ( rems . Count * RadixDigitsPerDigit [ radix ] + 1 ) ;
473
473
474
474
if ( _sign < 0 )
475
- sb . Append ( "-" ) ;
475
+ sb . Append ( '-' ) ;
476
476
477
477
char [ ] charBuf = new char [ RadixDigitsPerDigit [ radix ] ] ;
478
478
@@ -1575,10 +1575,7 @@ public int CompareTo(object obj)
1575
1575
return 1 ;
1576
1576
1577
1577
1578
- if ( ! ( obj is BigInteger o ) )
1579
- throw new ArgumentException ( "Expected a BigInteger to compare against" ) ;
1580
-
1581
- return Compare ( this , o ) ;
1578
+ return obj is BigInteger o ? Compare ( this , o ) : throw new ArgumentException ( "Expected a BigInteger to compare against" ) ;
1582
1579
}
1583
1580
1584
1581
#endregion
@@ -2009,7 +2006,7 @@ public BigInteger Abs()
2009
2006
public BigInteger Power ( int exp )
2010
2007
{
2011
2008
if ( exp < 0 )
2012
- throw new ArgumentOutOfRangeException ( " exp" , "Exponent must be non-negative" ) ;
2009
+ throw new ArgumentOutOfRangeException ( nameof ( exp ) , "Exponent must be non-negative" ) ;
2013
2010
2014
2011
if ( exp == 0 )
2015
2012
return One ;
@@ -2043,7 +2040,7 @@ public BigInteger ModPow(BigInteger power, BigInteger mod)
2043
2040
{
2044
2041
// TODO: Look at Java implementation for a more efficient version
2045
2042
if ( power < 0 )
2046
- throw new ArgumentOutOfRangeException ( " power" , "must be non-negative" ) ;
2043
+ throw new ArgumentOutOfRangeException ( nameof ( power ) , "must be non-negative" ) ;
2047
2044
2048
2045
if ( power . _sign == 0 )
2049
2046
return One ;
@@ -3014,8 +3011,8 @@ private static void DivMod(uint[] x, uint[] y, out uint[] q, out uint[] r)
3014
3011
// Special case: dividend == 0
3015
3012
if ( xlen == 0 )
3016
3013
{
3017
- q = new uint [ 0 ] ;
3018
- r = new uint [ 0 ] ;
3014
+ q = Array . Empty < uint > ( ) ;
3015
+ r = Array . Empty < uint > ( ) ;
3019
3016
return ;
3020
3017
}
3021
3018
@@ -3032,7 +3029,7 @@ private static void DivMod(uint[] x, uint[] y, out uint[] q, out uint[] r)
3032
3029
// Special case: dividend < divisor
3033
3030
if ( cmp < 0 )
3034
3031
{
3035
- q = new uint [ 0 ] ;
3032
+ q = Array . Empty < uint > ( ) ;
3036
3033
r = ( uint [ ] ) x . Clone ( ) ;
3037
3034
return ;
3038
3035
}
0 commit comments