我在查找快速計算BINARY(1024)字段的漢明重量/總體數/「1位數」的方法。 MySQL有一個BIT_COUNT函數可以做那樣的事情。我無法在T-SQL中找到類似的功能? 或者你會建議將二進制數據存儲在另一種類型的字段中? 如果你不知道我在說什麼,這裏是Wikipedia article about the hamming weight。
;if A is a 9 bit quantity, B gets number of 1's (Schroeppel)
IMUL A,[1001001001] ;4 copies
AND A,[42104210421] ;every 4th bit
IDIVI A,17 ;casting out 15.'s in hexadecimal
這個函數似乎需要第33位