【Swift 60秒】20 - Arithmetic operators_豪冷啊
Now you know all the basic types in Swift, we can start to put them together using operators. Operators are those little mathematical symbols like and , and Swift has a huge range of them.Here are a couple of test variables for us to work with:We can add...
0x00 Lesson
Now you know all the basic types in Swift, we can start to put them together using operators. Operators are those little mathematical symbols like +
and -
, and Swift has a huge range of them.
let firstScore = 12
let secondScore = 4
We can add and subtract using +
and -
:
let total = firstScore + secondScore
let difference = firstScore - secondScore
And we can multiply and divide using *
and /
:
let product = firstScore * secondScore
let divided = firstScore / secondScore
Swift has a special operator for calculating remainders after division: %
. It calculates how many times one number can fit inside another. then sends back the value that’s left over.
For example, we set secondScore to 4, so if we say 13 %
secondScore we’ll get back one, because 4 fits into 13 three times with remainder one:
let remainder = 13 % secondScore
0x01 Tips
the %
operator calculates division remainder
0x02 我的小作品
欢迎体验我的作品之一:小汉字-XHanzi
汉字书写入门,常用汉字 3800 个
App Store
搜索即可~
皇冠新体育APP相关的文章
- Bilateral Filters(双边滤波算法)的超简单原理,学不会你打我。_一蓑烟雨任平生~_双边滤波原理
- 全国多年平均降水量空间分布数据1951-2021年、气温分布数据、蒸散量数据、蒸发量数据、太阳辐射数据、日照数据、风速数据_地理遥感生态网_年平均降水量数据
- 数学建模竞赛常考三大模型及十大算法【预测模型、优化模型、评价模型】_延锋16_预测模型有哪些
- Android studio模拟器启动失败 The emulator process for AVD Pixel_2_API_29 was killed 之 配置环境变量_夏屿_
- UE4打包并加载Pak-Windows/iOS不同平台Editor/Runtime不同运行模式兼容_tangfuling1991_ue4 加载pak
- 全网最通俗易懂的 Self-Attention自注意力机制 讲解_越来越胖的GuanRunwei_自注意力机制详解
- Yolov5(v6.1)数据增强方式解析_迪菲赫尔曼_yolov5数据增强
- 皇冠新体育APP:Unity 接入Apple登录_Zyt吖_unity接入苹果登录
- Apple Pencil 一代和二代有什么区别_地推
- 皇冠新体育APP:社区发现算法??Louvain 算法_东方小虾米_louvain
- AVAudioSession - Category、Model、Options、Error参数详解_Cao_Shixin攻城狮
- 基于改进SEIR模型分析上海疫情_Cachel wood_seir模型评价
- mac m1使用免费的hopper demo版本和machoView破解修改iphone上的app_小手琴师
- 【保研】2021南京大学计算机夏令营笔试面试笔记_echoliuy
- 皇冠新体育APP:Android Studio配置国内镜像源_在角落里123_android studio 国内源
- MachOView使用_LAY_R_machoview