当前位置:网站首页>How to convert a decimal number to binary in swift
How to convert a decimal number to binary in swift
2022-07-03 12:38:00 【iWillook】

Image Excerpt From: Apple Inc. “The Swift Programming Language (Swift 5.3).” Apple Books. https://books.apple.com/us/book/the-swift-programming-language-swift-5-4/id881256329
//
// main.swift
// Ultimate
//
// Created by Mewlan Musajan on 5/7/21.
//
// Excerpt From: SINKUK KANG “How to convert a decimal number to binary in Swift?” stackoverflow. https://www.xspdf.com/help/51882984.html
extension BinaryInteger {
var binaryDescription: String {
var binaryString = ""
var internalNumber = self
for _ in (1...self.bitWidth) {
binaryString.insert(contentsOf: "\(internalNumber & 1)", at: binaryString.startIndex)
internalNumber >>= 1
}
return "0b" + binaryString
}
}
print(Int8(~0b00001111).binaryDescription)
边栏推荐
- If you can't learn, you have to learn. Jetpack compose writes an im app (II)
- 239. Sliding window maximum
- regular expression
- Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
- 记录自己vulnhub闯关记录
- [ManageEngine] the role of IP address scanning
- Prompt unread messages and quantity before opening chat group
- 1-2 project technology selection and structure
- 111. Minimum depth of binary tree
- Pki/ca and digital certificate
猜你喜欢

The latest version of blind box mall thinkphp+uniapp

记录自己vulnhub闯关记录

If you can't learn, you have to learn. Jetpack compose writes an im app (II)

Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)

Idea packages the web project into a war package and deploys it to the server to run

Wechat applet - basic content
![Sword finger offer03 Repeated numbers in the array [simple]](/img/cf/c1ad2f2a45560b674b5b8c11fed244.png)
Sword finger offer03 Repeated numbers in the array [simple]

Sword finger offer05 Replace spaces
![Sword finger offer04 Search in two-dimensional array [medium]](/img/c4/002c951f8d914aaea4f4133685ebd1.png)
Sword finger offer04 Search in two-dimensional array [medium]

剑指Offer06. 从尾到头打印链表
随机推荐
regular expression
What is more elegant for flutter to log out and confirm again?
实现验证码验证
Flutter 退出登录二次确认怎么做才更优雅?
The best shortcut is no shortcut
Dix règles de travail
Fundamentals of concurrent programming (III)
Is it OK to open an account for online stock speculation? Is the fund safe?
雲計算未來 — 雲原生
Display time with message interval of more than 1 minute in wechat applet discussion area
Sword finger offer06 Print linked list from end to end
2020-09_ Shell Programming Notes
JVM内存模型
Approve iPad, which wants to use your icloud account
Integer int compare size
Sqoop1.4.4原生增量导入特性探秘
十條職場規則
Adult adult adult
2021 autumn Information Security Experiment 1 (password and hiding technology)
Eureka self protection