Are bit operations quick?
        Posted  
        
            by flashnik
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by flashnik
        
        
        
        Published on 2010-05-10T22:10:06Z
        Indexed on 
            2010/05/10
            22:14 UTC
        
        
        Read the original article
        Hit count: 350
        
I'm dealing with a problem which needs to work with a lot of data. Currently its' values are represented as unsigned int. I know that real values do not exceed some limit, say 1000. That means that I can use unsigned short to store it. One profit is that it'll use less space. Do I have to pay for it by loosing in performance?
Another assumption. I decided to store data as short but all calling functions use int, so I need to convert between these datatypes when storing/extracting values. Wiil the performance lost be dramatic?
Third assumption. Due to great wish to econom memory I decided to use not short but just 10 bits packed into array of unsigned int. What will happen in this case comparing with previous ones?
© Stack Overflow or respective owner