1
- """
1
+ """ "
2
2
__Predicates__ are functions that ask "yes or no" questions of their argument[s].
3
3
You can ask of a number "Is this zero?" or "Is this one?" and these predicates
4
4
(`iszero`, `isone`) will work as expected with almost all numerical types.
@@ -16,64 +16,64 @@ These are the predicates made available for use with DoubleFloats:
16
16
iseven, isodd, # isinteger(value/2.0), !isinteger(value/2.0)
17
17
""" predicates
18
18
19
- isnonzero (x:: T ) where {T<: Real } = ! iszero (x)
20
- ispos (x:: T ) where {T<: Real } = ! isneg (x) && isnonzero (x)
21
- isnonneg (x:: T ) where {T<: Real } = ! isneg (x)
22
- isnonpos (x:: T ) where {T<: Real } = isneg (x) || iszero (x)
23
- isfractional (x:: T ) where {T<: Real } = abs (x) < one (T)
19
+ isnonzero (x:: T ) where {T<: AbstractFloat } = ! iszero (x)
20
+ ispos (x:: T ) where {T<: AbstractFloat } = ! isneg (x) && isnonzero (x)
21
+ isnonneg (x:: T ) where {T<: AbstractFloat } = ! isneg (x)
22
+ isnonpos (x:: T ) where {T<: AbstractFloat } = isneg (x) || iszero (x)
23
+ isfractional (x:: T ) where {T<: AbstractFloat } = abs (x) < one (T)
24
24
25
25
26
- iszero (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
26
+ iszero (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
27
27
iszero (HI (x)) # && iszero(LO(x))
28
28
29
- isnonzero (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
29
+ isnonzero (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
30
30
! iszero (HI (x)) # || !iszero(LO(x))
31
31
32
- isone (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
32
+ isone (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
33
33
isone (HI (x)) && iszero (LO (x))
34
34
35
- ispos (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
35
+ ispos (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
36
36
! signbit (HI (x)) && ! iszero (HI (x))
37
37
38
- isneg (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
38
+ isneg (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
39
39
signbit (HI (x))
40
40
41
- isnonneg (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
41
+ isnonneg (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
42
42
! signbit (HI (x))
43
43
44
- isnonpos (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
44
+ isnonpos (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
45
45
signbit (HI (x)) || iszero (HI (x))
46
46
47
- isfinite (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
47
+ isfinite (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
48
48
isfinite (HI (x)) # # && isfinite(LO(x))
49
49
50
- isinf (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
50
+ isinf (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
51
51
isinf (HI (x)) && iszero (LO (x))
52
52
53
- isposinf (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
53
+ isposinf (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
54
54
isinf (HI (x)) && ! signbit (HI (x))
55
55
56
- isneginf (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
56
+ isneginf (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
57
57
isinf (HI (x)) && signbit (HI (x))
58
58
59
- isnan (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
59
+ isnan (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
60
60
isnan (HI (x)) # # && iszero(LO(x))
61
61
62
- issubnormal (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
62
+ issubnormal (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
63
63
issubnormal (LO (x)) || issubnormal (HI (x))
64
64
65
- isinteger (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
65
+ isinteger (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
66
66
isinteger (HI (x)) && isinteger (LO (x))
67
67
68
- isfractional (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
68
+ isfractional (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
69
69
! isinteger (LO (x)) || ! isinteger (HI (x))
70
70
71
- isodd (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
71
+ isodd (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
72
72
iszero (LO (x)) ?
73
73
isinteger (HI (x)) && isodd (HI (x)) :
74
74
isinteger (LO (x)) && isodd (LO (x))
75
75
76
- iseven (x:: Double{T,E} ) where {T<: Real ,E<: Emphasis } =
76
+ iseven (x:: Double{T,E} ) where {T<: AbstractFloat ,E<: Emphasis } =
77
77
iszero (LO (x)) ?
78
78
isinteger (HI (x)) && iseven (HI (x)) :
79
79
isinteger (LO (x)) && iseven (LO (x))
0 commit comments