当前位置:网站首页>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)
边栏推荐
- Shutter widget: centerslice attribute
- 111. Minimum depth of binary tree
- adb push apk
- 剑指Offer10- I. 斐波那契数列
- Eureka self protection
- Public and private account sending prompt information (user microservice -- message microservice)
- initial、inherit、unset、revert和all的区别
- 写一个简单的nodejs脚本
- Keep learning swift
- LeetCode 0556.下一个更大元素 III - 4步讲完
猜你喜欢

T430 toss and install OS majave 10.14

Wechat applet - basic content

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

实现验证码验证

Fluent: Engine Architecture

Self made pop-up input box, input text, and click to complete the event.

The future of cloud computing cloud native

Shutter widget: centerslice attribute

Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.

Record your vulnhub breakthrough record
随机推荐
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
强大的头像制作神器微信小程序
Sword finger offer07 Rebuild binary tree
elastic_ L02_ install
flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
2.7 overview of livedata knowledge points
2.6 preliminary cognition of synergetic couroutines
阿里大于发送短信(用户微服务--消息微服务)
error: expected reference but got (raw string)
02_ Lock the code, and don't let the "lock" become a worry
Alibaba is bigger than sending SMS (user microservice - message microservice)
Everything comes to him who waits
双链笔记·思源笔记综合评测:优点、缺点、评价
What is more elegant for flutter to log out and confirm again?
The best shortcut is no shortcut
wpa_ cli
01_ Using the concurrent tool class library, is thread safety safe
New features of ES6
最新版盲盒商城thinkphp+uniapp
1-1 token