Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

'1 << stuff' = 'bit shift left 1 by stuff many positions'. Say you have a byte, 8 bits, '1' is 00000001 - if we shift it left 3 bits we have 00001000 (8).

'Stuff' there is just any expression (to understand separately) that evaluates to the number of positions to shift; `<<` is the operator for bit-shifting (left, cf. `>>`).

In brief `(s[i - window_size] as u32 - 'a' as u32)` is finding the character that just left the window on the left, represented as a number, starting from 'a' as 0 so that all 26 fit inside 32 bit positions.



Thank you all who kindly took to answering my question. It makes sense now!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: