gunw avatar

[Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators

gunw

Published: 25 Jan 2019 › Updated: 25 Jan 2019[Grammer] 16 - Overflow Operators, 17 - Comparison Operators, 18 - Logical Operators

[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:

Written by

User

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