@@ -11,7 +11,7 @@ import .Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), xor,
1111 bin, oct, dec, hex, isequal, invmod, _prevpow2, _nextpow2, ndigits0zpb,
1212 widen, signed, unsafe_trunc, trunc, iszero, isone, big, flipsign, signbit,
1313 sign, isodd, iseven, digits!, hash, hash_integer, top_set_bit,
14- clamp, unsafe_takestring
14+ ispositive, isnegative, clamp, unsafe_takestring
1515
1616import Core: Signed, Float16, Float32, Float64
1717
@@ -383,7 +383,7 @@ function (::Type{T})(x::BigInt) where T<:Base.BitSigned
383383 else
384384 0 <= n <= cld (sizeof (T),sizeof (Limb)) || throw (InexactError (nameof (T), T, x))
385385 y = x % T
386- ispos (x) ⊻ (y > 0 ) && throw (InexactError (nameof (T), T, x)) # catch overflow
386+ ispositive (x) ⊻ (y > 0 ) && throw (InexactError (nameof (T), T, x)) # catch overflow
387387 y
388388 end
389389end
@@ -606,7 +606,7 @@ Number of ones in the binary representation of abs(x).
606606count_ones_abs (x:: BigInt ) = iszero (x) ? 0 : MPZ. mpn_popcount (x)
607607
608608function top_set_bit (x:: BigInt )
609- isneg (x) && throw (DomainError (x, " top_set_bit only supports negative arguments when they have type BitSigned." ))
609+ isnegative (x) && throw (DomainError (x, " top_set_bit only supports negative arguments when they have type BitSigned." ))
610610 iszero (x) && return 0
611611 x. size * sizeof (Limb) << 3 - leading_zeros (GC. @preserve x unsafe_load (x. d, x. size))
612612end
@@ -700,7 +700,7 @@ function prod(arr::AbstractArray{BigInt})
700700 foldl (MPZ. mul!, arr; init)
701701end
702702
703- factorial (n:: BigInt ) = ! isneg (n) ? MPZ. fac_ui (n) : throw (DomainError (n, " `n` must not be negative." ))
703+ factorial (n:: BigInt ) = ! isnegative (n) ? MPZ. fac_ui (n) : throw (DomainError (n, " `n` must not be negative." ))
704704
705705function binomial (n:: BigInt , k:: Integer )
706706 k < 0 && return BigInt (0 )
@@ -732,17 +732,17 @@ isone(x::BigInt) = x == Culong(1)
732732< (i:: Integer , x:: BigInt ) = cmp (x,i) > 0
733733< (x:: BigInt , f:: CdoubleMax ) = isnan (f) ? false : cmp (x,f) < 0
734734< (f:: CdoubleMax , x:: BigInt ) = isnan (f) ? false : cmp (x,f) > 0
735- isneg (x:: BigInt ) = x. size < 0
736- ispos (x:: BigInt ) = x. size > 0
735+ isnegative (x:: BigInt ) = x. size < 0
736+ ispositive (x:: BigInt ) = x. size > 0
737737
738- signbit (x:: BigInt ) = isneg (x)
738+ signbit (x:: BigInt ) = isnegative (x)
739739flipsign! (x:: BigInt , y:: Integer ) = (signbit (y) && (x. size = - x. size); x)
740740flipsign ( x:: BigInt , y:: Integer ) = signbit (y) ? - x : x
741741flipsign ( x:: BigInt , y:: BigInt ) = signbit (y) ? - x : x
742742# above method to resolving ambiguities with flipsign(::T, ::T) where T<:Signed
743743function sign (x:: BigInt )
744- isneg (x) && return - one (x)
745- ispos (x) && return one (x)
744+ isnegative (x) && return - one (x)
745+ ispositive (x) && return one (x)
746746 return x
747747end
748748
@@ -754,12 +754,12 @@ function string(n::BigInt; base::Integer = 10, pad::Integer = 1)
754754 iszero (n) && pad < 1 && return " "
755755 nd1 = ndigits (n, base= base)
756756 nd = max (nd1, pad)
757- sv = Base. StringMemory (nd + isneg (n))
757+ sv = Base. StringMemory (nd + isnegative (n))
758758 GC. @preserve sv MPZ. get_str! (pointer (sv) + nd - nd1, base, n)
759- @inbounds for i = (1 : nd- nd1) .+ isneg (n)
759+ @inbounds for i = (1 : nd- nd1) .+ isnegative (n)
760760 sv[i] = ' 0' % UInt8
761761 end
762- isneg (n) && (sv[1 ] = ' -' % UInt8)
762+ isnegative (n) && (sv[1 ] = ' -' % UInt8)
763763 unsafe_takestring (sv)
764764end
765765
@@ -769,7 +769,7 @@ function digits!(a::AbstractVector{T}, n::BigInt; base::Integer = 10) where {T<:
769769 # fast path using mpz_get_str via string(n; base)
770770 s = codeunits (string (n; base))
771771 i, j = firstindex (a)- 1 , length (s)+ 1
772- lasti = min (lastindex (a), firstindex (a) + length (s)- 1 - isneg (n))
772+ lasti = min (lastindex (a), firstindex (a) + length (s)- 1 - isnegative (n))
773773 while i < lasti
774774 # base ≤ 36: 0-9, plus a-z for 10-35
775775 # base > 36: 0-9, plus A-Z for 10-35 and a-z for 36..61
@@ -778,14 +778,14 @@ function digits!(a::AbstractVector{T}, n::BigInt; base::Integer = 10) where {T<:
778778 end
779779 lasti = lastindex (a)
780780 while i < lasti; a[i+= 1 ] = zero (T); end
781- return isneg (n) ? map! (- ,a,a) : a
781+ return isnegative (n) ? map! (- ,a,a) : a
782782 elseif a isa StridedVector{<: Base.BitInteger } && stride (a,1 ) == 1 && ispow2 (base) && base- 1 ≤ typemax (T)
783783 # fast path using mpz_export
784784 origlen = length (a)
785785 _, writelen = MPZ. export! (a, n; nails = 8 sizeof (T) - trailing_zeros (base))
786786 length (a) != origlen && resize! (a, origlen) # truncate to least-significant digits
787787 a[begin + writelen: end ] .= zero (T)
788- return isneg (n) ? map! (- ,a,a) : a
788+ return isnegative (n) ? map! (- ,a,a) : a
789789 end
790790 end
791791 return invoke (digits!, Tuple{typeof (a), Integer}, a, n; base) # slow generic fallback
@@ -917,7 +917,7 @@ module MPQ
917917
918918# Rational{BigInt}
919919import . Base: unsafe_rational, __throw_rational_argerror_zero
920- import .. GMP: BigInt, MPZ, Limb, isneg, libgmp
920+ import .. GMP: BigInt, MPZ, Limb, libgmp
921921
922922gmpq (op:: Symbol ) = (Symbol (:__gmpq_ , op), libgmp)
923923
995995# define add, sub, mul, div, and their inplace versions
996996function add! (z:: Rational{BigInt} , x:: Rational{BigInt} , y:: Rational{BigInt} )
997997 if iszero (x. den) || iszero (y. den)
998- if iszero (x. den) && iszero (y. den) && isneg (x. num) != isneg (y. num)
998+ if iszero (x. den) && iszero (y. den) && isnegative (x. num) != isnegative (y. num)
999999 throw (DivideError ())
10001000 end
10011001 return set! (z, iszero (x. den) ? x : y)
@@ -1008,7 +1008,7 @@ end
10081008
10091009function sub! (z:: Rational{BigInt} , x:: Rational{BigInt} , y:: Rational{BigInt} )
10101010 if iszero (x. den) || iszero (y. den)
1011- if iszero (x. den) && iszero (y. den) && isneg (x. num) == isneg (y. num)
1011+ if iszero (x. den) && iszero (y. den) && isnegative (x. num) == isnegative (y. num)
10121012 throw (DivideError ())
10131013 end
10141014 iszero (x. den) && return set! (z, x)
@@ -1025,7 +1025,7 @@ function mul!(z::Rational{BigInt}, x::Rational{BigInt}, y::Rational{BigInt})
10251025 if iszero (x. num) || iszero (y. num)
10261026 throw (DivideError ())
10271027 end
1028- return set_si! (z, ifelse (xor (isneg (x. num), isneg (y. num)), - 1 , 1 ), 0 )
1028+ return set_si! (z, ifelse (xor (isnegative (x. num), isnegative (y. num)), - 1 , 1 ), 0 )
10291029 end
10301030 zq = _MPQ (z)
10311031 ccall ((:__gmpq_mul , libgmp), Cvoid,
@@ -1038,7 +1038,7 @@ function div!(z::Rational{BigInt}, x::Rational{BigInt}, y::Rational{BigInt})
10381038 if iszero (y. den)
10391039 throw (DivideError ())
10401040 end
1041- isneg (y. num) || return set! (z, x)
1041+ isnegative (y. num) || return set! (z, x)
10421042 return set_si! (z, flipsign (- 1 , x. num), 0 )
10431043 elseif iszero (y. den)
10441044 return set_si! (z, 0 , 1 )
0 commit comments