function gmp_shiftl($x,$n) { // shift left
return(gmp_mul($x,gmp_pow(2,$n)));
}
function gmp_shiftr($x,$n) { // shift right
return(gmp_div_q($x,gmp_pow(2,$n)));
}
Notes contributed by Nitrogen. May be helpful for someone else too.
function gmp_shiftl($x,$n) { // shift left
return(gmp_mul($x,gmp_pow(2,$n)));
}
function gmp_shiftr($x,$n) { // shift right
return(gmp_div_q($x,gmp_pow(2,$n)));
}
For those who wish to do bitwise shifting, it's quite simple.. to shift left, just multiply the number by pow(2,x), and to shift right, divide by pow(2,x).
发布评论
评论(1)
注释氮由氮气贡献。也可能对别人有帮助。
Notes contributed by Nitrogen. May be helpful for someone else too.