DELIMITER $$

DROP FUNCTION IF EXISTS `value_of_bit_index`$$
/*计算数字的某个位的值*/
CREATE FUNCTION `value_of_bit_index`(`number` int, `idx` int) RETURNS int(11)
BEGIN
RETURN (`number` >> (`idx`-1)) ^ ((`number` >> `idx`-1) &~1);
END$$

DELIMITER ;

05-07 15:15