Published: 25 Jan 2019 › Updated: 25 Jan 2019![[Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators](/nhc-explorer-cover.webp)
![[Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators](/nhc-explorer-cover.webp)
[Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators
- Overflow Operatiors
&+ : Overflow Addition Operator
&- : Overflow Subtraction Operator
&*: Overflow Multiplication Operator
let a: Int8 = Int8.max
let result = a &+ 1 // -128
let b: Int8 = Int8.min
let result2 = a &- 1 // 127
- Comparison Operators : ==, !=, >, <, >=, <=
항상 이항연산자로 사용되고, 반환값은 Bool 타입이다.
let a = 0
let b = 1
let c = 1
a == b // false
b != c // false
a > b // false
b > c // false
b >= c // true
- Logical Operators : 모든 논리연산의 반환값은 Bool 타입이다.
&&(Logical AND Operator) : 둘 중 하나라도 false이면 false, 아니면 true
||(Logical OR Operator) : 둘 중 하나라도 true이면 true, 아니면 false
!(Logical NOT Operator) : true -> false, false -> true
let num = 11
if num > 10 && num % 2 == 0 {
print(true)
} else {
print(false)
}
// false
Leave [Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators to:
Read more #swift4 posts
Best Posts From gunw
We have not curated any of gunw's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From gunw
- [Grammer] 26 - Custom Operators
- [Grammer] 25 - Operator Methods
- [Grammer] 23 - Bitwise Operators, 24 - Identity Operator
- [Grammer]21 - Ternary Coditional Operator, 22 - Range Operators
- [Grammer] 19 - Short-circuit Evaluation, Side Effect, 20 - Assignment Operators
- [Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators
- [Grammer] 13 - Data Types with Memory, 14 - Operator Basics, 15 - Arithmetic Operators
- [Grammer] 11 - Type Inference, Type Safety, 12 - Type Conversion, Type Aliases
- [Grammer] 09 - Boolean, 10 - Strings and Characters
- [Grammer] 07 - Naming Convention, 08 - Numbers