V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  phcbest  ›  全部回复第 1 页 / 共 1 页
回复总数  3
我感觉 Compose 和 KMP 完全不是一个东西,学 KMP 不如直接上 flutter 了,Compose 纯原生开发提效很爽
APP 没适配 A14 特性,一般引入了下面这个权限的都是主动适配了的
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
2023-06-11 22:48:32 +08:00
回复了 ellermister 创建的主题 程序员 能否用你所熟悉的开发语言,实现基础四则运算?
```kotlin
fun add(a: Int, b: Int): Int {
var carry: Int
var sum: Int
do {
sum = a xor b
carry = (a and b) shl 1
a = sum
b = carry
} while (b != 0)
return a
}

fun subtract(a: Int, b: Int): Int {
return add(a, add(b.inv(), 1))
}

fun multiply(a: Int, b: Int): Int {
var result = 0
var shift = 0
var bCopy = b
while (bCopy != 0) {
if (bCopy and 1 == 1) {
result = add(result, a shl shift)
}
shift++
bCopy = bCopy shr 1
}
return result
}

fun divide(a: Int, b: Int): Int {
var dividend = a
var divisor = b
var quotient = 0
while (dividend >= divisor) {
dividend = subtract(dividend, divisor)
quotient = add(quotient, 1)
}
return quotient
}
```
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1268 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 23:21 · PVG 07:21 · LAX 16:21 · JFK 19:21
Developed with CodeLauncher
♥ Do have faith in what you're doing.