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 ;

posted on 2018-09-13 17:52  袁晓平  阅读(279)  评论(0编辑  收藏  举报