Tag: 位运算符

如何结合Kotlin中的Intent标志

我想结合两个intent标志,就像我们在android中做的那样 Intent intent = new Intent(this, MapsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); 我试图做这样的事情,但它不适合我 val intent = Intent(context, MapActivity::class.java) intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)

按位“和”操作进入kotlin

如果负数是从-31到-1,那么我想将其表示为111XXXXX格式。 我尝试使用“和”按位运算符: println("0b00011111 & 0xe0 is ${0b00011111 and 0xe0}") println("31 & 0xe0 is ${31 and 0xe0}") println("0b00011111 & 0b11100000 is ${0b00011111 and 0b11100000}") 但是结果总是0.我犯了什么错误?