package com.viatris.patient.core.model.operation; class Main{ private static long tag = 0L; private static long OPERATOR = 1L << 3; private static long DOCTOR = 1L << 1; public static void main(String[] args) { long a = 0b1000; long b = 0b10; // 加tag tag |= OPERATOR; System.out.println(tag); tag |= DOCTOR; System.out.println(tag); // 比较tag System.out.println(a==OPERATOR); System.out.println(b==DOCTOR); System.out.println(tag&OPERATOR); System.out.println(tag&DOCTOR); // 去tag tag&=(~OPERATOR); System.out.println(tag); tag&=(~DOCTOR); System.out.println(tag); } }
位运算55
最新推荐文章于 2024-11-08 14:58:24 发布