bitwise operators - What is the most portable way to get/set highest bit of an integer in GNU C -


what portable way get/set highest bit of integer in gnu c?

this bloomberg interview question. didn't give best answer @ time. can answer it?

thanks

if type unsigned, it's easy:

(type)-1-(type)-1/2 

for signed values, know no way. if find way, answer several unanswered questions on so:

c question: off_t (and other signed integer types) minimum , maximum values

is there way compute width of integer type @ compile-time?

maybe others.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -