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

I think there’s an Intel intrinsic for this, but nonetheless neat.


It's the kind of thing that I would expect a compiler to know about and use; when writing code in a high level language you shouldn't have to think too much about what happens on the hardware level.


It's done in Java, Integer.lowestOneBit(int), citing HD 2-1. Java defines ints to be 2-complimentary. I can't recall if it's compiled tzcnt[0], though

[0]: https://www.felixcloutier.com/x86/tzcnt




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

Search: