#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: AppBitUtils.py
 @DateTime: 2025/4/23 16:40
 @SoftWare: PyCharm
 @Author  ：xsh
"""
from PyQt5 import Qt

class AppBitUtils:
    @staticmethod
    def set_bit(number: int, bit_position: int, enable: bool) -> int:
        """
        Set the bit at the specified position to 1 or 0
        
        Args:
            number: The original number
            bit_position: The position of the bit to set (0-based)
            enable: True to set bit to 1, False to set bit to 0
            
        Returns:
            The number with the specified bit set to 1 or 0
        """
        if enable:
            return number | (1 << bit_position)
        else:
            return number & ~(1 << bit_position)
    
    @staticmethod
    def get_bit(number: int, bit_position: int) -> int:
        """
        Get the value of the bit at the specified position
        
        Args:
            number: The number to check
            bit_position: The position of the bit to get (0-based)
            
        Returns:
            0 or 1 depending on the bit value
        """
        return (number >> bit_position) & 1
