Reader small image

You're reading from  Swift Cookbook - Second Edition

Product typeBook
Published inFeb 2021
Reading LevelIntermediate
PublisherPackt
ISBN-139781839211195
Edition2nd Edition
Languages
Tools
Right arrow
Authors (2):
Keith Moon
Keith Moon
author image
Keith Moon

Keith Moon is an award-winning iOS developer, author and speaker based in London. He has worked with some of the biggest companies in the world to create engaging and personal mobile experiences. Keith has been developing in Swift since its release, working on projects both fully Swift, and mixed Swift and Objective-C. Keith has been invited to speak about Swift development in conferences from Moscow to Minsk and London.
Read more about Keith Moon

Chris Barker
Chris Barker
author image
Chris Barker

Chris Barker is an iOS developer and tech lead for fashion retailer N Brown (JD Williams, SimplyBe, Jacamo), where he heads up the iOS team. Chris started his career developing .NET applications for online retailer dabs (now BT Shop) before he made his move into mobile app development with digital agency Openshadow (now MyStudioFactory Paris). There, he worked on mobile apps for clients such as Louis Vuitton, L'Oréal Paris, and the Paris Metro. Chris often attends and speaks at local iOS developer meetups and conferences such as NSManchester, Malaga Mobile, and CodeMobile.
Read more about Chris Barker

View More author details
Right arrow

Using advanced operators

Swift is a programming language that takes a relatively small number of well-defined principles and builds on them to create expressive and powerful language features. The concept of mathematical operators, such as +, -, *, and / for addition, subtraction, multiplication, and division, respectively, seems so fundamental as to not warrant a mention. However, in Swift, this common mathematical functionality is built on top of an underlying operator system that is extensible and powerful.

In this recipe, we will look at some of the more advanced operators provided by the Swift standard library, and in the next recipe, we will create our own custom operators.

How to do it...

The operators we will explore are known as bitwise operators and are used to manipulate numerical bit representations.

An integer value in Swift can be represented in its binary form by prefixing the integer literal with 0b:

let zero: Int  = 0b000 
let one: Int = 0b001
let two: Int = 0b010...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Swift Cookbook - Second Edition
Published in: Feb 2021Publisher: PacktISBN-13: 9781839211195

Authors (2)

author image
Keith Moon

Keith Moon is an award-winning iOS developer, author and speaker based in London. He has worked with some of the biggest companies in the world to create engaging and personal mobile experiences. Keith has been developing in Swift since its release, working on projects both fully Swift, and mixed Swift and Objective-C. Keith has been invited to speak about Swift development in conferences from Moscow to Minsk and London.
Read more about Keith Moon

author image
Chris Barker

Chris Barker is an iOS developer and tech lead for fashion retailer N Brown (JD Williams, SimplyBe, Jacamo), where he heads up the iOS team. Chris started his career developing .NET applications for online retailer dabs (now BT Shop) before he made his move into mobile app development with digital agency Openshadow (now MyStudioFactory Paris). There, he worked on mobile apps for clients such as Louis Vuitton, L'Oréal Paris, and the Paris Metro. Chris often attends and speaks at local iOS developer meetups and conferences such as NSManchester, Malaga Mobile, and CodeMobile.
Read more about Chris Barker