Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between 0 << 16 and 0 << 20?

Tags:

c

objective-c

What is the difference between 0 << 16 and 0 << 20? I found it in UIViewAnimationOptions.

like image 250
Voloda2 Avatar asked Nov 30 '22 07:11

Voloda2


2 Answers

There isn't. They are both 0

   UIViewAnimationOptionTransitionNone            = 0 << 20,
   UIViewAnimationOptionTransitionFlipFromLeft    = 1 << 20,
   UIViewAnimationOptionTransitionFlipFromRight   = 2 << 20,
   UIViewAnimationOptionTransitionCurlUp          = 3 << 20,
   UIViewAnimationOptionTransitionCurlDown        = 4 << 20,
   UIViewAnimationOptionTransitionCrossDissolve   = 5 << 20,
   UIViewAnimationOptionTransitionFlipFromTop     = 6 << 20,
   UIViewAnimationOptionTransitionFlipFromBottom  = 7 << 20,

The UIViewAnimationOptionTransition settings are all concerned with setting the bits 20-23. UIViewAnimationOptionTransitionNone is zero, however, it is defined in the same manner as the other UIViewAnimationTransitions for consistency.

Both of the given values are zero which indicates they are both the default settings, if you don't pass transition flag you'll get no transition by default. But you can also specify that explicitly.

like image 112
Winston Ewert Avatar answered Dec 04 '22 07:12

Winston Ewert


0 << 16 is shifting left 16 bits, 0 << 20 shifting 20 bits. Both end up being 0.

I'm guessing it's being done for clarity, just like sizeof(char) is sometimes used in malloc.

like image 29
Pubby Avatar answered Dec 04 '22 05:12

Pubby