Style note, separate boolean logic operators with spaces:

```scala
if(.... && bits >= res)
```