2017-06-27 44 views
2

RFC1321這是比較假人嗎?

我發現這段代碼:

if ((context->count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3)) 
    context->count[1]++; 
context->count[1] += ((UINT4)inputLen >> 29); 

我不明白的比較:

((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3)) 

它就像它總是返回0,對不對?

+1

因爲你被錯誤評估的條件。比較'context-> count [0] + =((UINT4)inputLen << 3)'與'((UINT4)inputLen << 3)的結果' – LPs

+0

我的錯誤...括號過多 – nowox

+1

Lets not write UINT4 u4 = inputLen << 3; context-> count [0] + = u4;如果(context-> count [0] Lundin

回答

7

沒有這種比較。看括號是如何配對:

這是

(X < ((UINT4)inputLen << 3)) 

其中X =

(context->count[0] += ((UINT4)inputLen << 3))