当前位置:网站首页>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)
边栏推荐
- 1-1 token
- 111. Minimum depth of binary tree
- What is more elegant for flutter to log out and confirm again?
- Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
- error: expected reference but got (raw string)
- Introduction to concurrent programming (I)
- Is it OK to open an account for online stock speculation? Is the fund safe?
- Dart: self study system
- 云计算未来 — 云原生
- 剑指Offer05. 替换空格
猜你喜欢
Pki/ca and digital certificate
initial、inherit、unset、revert和all的区别
Sword finger offer05 Replace spaces
剑指Offer05. 替换空格
Implement verification code verification
剑指Offer06. 从尾到头打印链表
阿里 & 蚂蚁自研 IDE
Itext7 uses iexternalsignature container for signature and signature verification
阿里大于发送短信(用户微服务--消息微服务)
LeetCode 0556. Next bigger element III - end of step 4
随机推荐
Alibaba is bigger than sending SMS (user microservice - message microservice)
flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
Official website of Unicode query
Introduction to concurrent programming (II)
The difference between lambda and anonymous inner class
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
使用BLoC 构建 Flutter的页面实例
Integer int compare size
初入职场,如何快速脱颖而出?
Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
Swift5.7 扩展 some 到泛型参数
Recovery of website address and method of Amazon account login two-step verification failure caused by mobile phone number becoming empty
Public and private account sending prompt information (user microservice -- message microservice)
十條職場規則
adb push apk
lambda与匿名内部类的区别
Kung Fu pays off, and learning is done
239. Sliding window maximum
Oh my Zsh + TMUX installation
02_ Lock the code, and don't let the "lock" become a worry