C bitwise operators 🔣

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 81

  • @BroCodez
    @BroCodez  3 года назад +58

    #include

    int main()
    {
    // BITWISE OPERATORS = special operators used in bit level programming
    // (knowing binary is important for this topic)
    // & = AND
    // | = OR
    // ^ = XOR
    // > right shift
    int x = 6; // 6 = 00000110
    int y = 12; // 12 = 00001100
    int z = 0; // 0 = 00000000
    z = x & y;
    printf("AND = %d
    ", z);
    z = x | y;
    printf("OR = %d
    ", z);
    z = x ^ y;
    printf("XOR = %d
    ", z);
    z = x > 2;
    printf("SHIFT RIGHT = %d
    ", z);
    return 0;
    }

    • @namansalgotra6293
      @namansalgotra6293 Год назад +1

      What software do you use?

    • @Abon963
      @Abon963 Год назад +1

      ​@@namansalgotra6293If you are talking about where he writes the code it’s "Vs code"

    • @md.lutfullahillabib
      @md.lutfullahillabib 4 месяца назад

      where is you "Bitwise Complement Operator (~ tilde) in c" tutorial? @BroCodez

  • @sevanthishekar4379
    @sevanthishekar4379 7 месяцев назад +49

    Quick Note: For Shift Left, like Bro mentioned there's a pattern.....every time you shift it, it doubles.
    Ex: int x = 6;
    for x

    • @spacewizerd
      @spacewizerd 5 месяцев назад +1

      thats cool
      thx man

    • @rickgrimes47
      @rickgrimes47 Месяц назад +1

      Similarly Right Shift, x>>n = x/2^n, where 2^n is 2 raise to the power n.

  • @tomsterbg8130
    @tomsterbg8130 Год назад +37

    This was very easy to understand and while being really descriptive, thank you so much for making that video!

  • @keynadaby
    @keynadaby 27 дней назад +1

    I finally understood it!! I was so confused with CS50 week 4 PSET recover, now I got it, thanks!

  • @xbaleks4609
    @xbaleks4609 Год назад +21

    better than a course that i bought (74.99$) on udemy...
    Thank you, very clear and understandable.

    • @MerrowGula
      @MerrowGula 5 месяцев назад +2

      you know that the udemy courses have discounts right ?

    • @guilhermecampos8313
      @guilhermecampos8313 4 месяца назад +1

      Warning: just buy udemy courses when they are on sale. It happens very often (something like every other week).

  • @guillaumelacroix8730
    @guillaumelacroix8730 Год назад +12

    you are a legend mate! Thank you for this clear explanation!

  • @Garrison86
    @Garrison86 2 года назад +2

    Awesome thanks for the demo on bit wise operators, super easy to understand 👍👍👍👍

  • @arnavtripathiyo
    @arnavtripathiyo 8 месяцев назад +2

    Thank you so much very easy to understand because of your video

  • @saiganeshj10
    @saiganeshj10 29 дней назад

    wonderfully explained. awesome. You are the real G.

  • @antoinebguitar2869
    @antoinebguitar2869 8 месяцев назад +2

    Oh so those scary looking math equations are actually just logic gates and boolean algebra lol

  • @LBCreateSpace
    @LBCreateSpace 2 месяца назад

    Amazing explanation. Thank you

  • @nataaalia
    @nataaalia 10 месяцев назад

    Such a good explanation

  • @ronalbocher4159
    @ronalbocher4159 10 месяцев назад

    Thank you so much! Extremely clear, amazing explanations!

  • @SuperIL12
    @SuperIL12 6 месяцев назад

    Excellent! Perfect explanation!

  • @marcusviniciusalves4199
    @marcusviniciusalves4199 20 дней назад

    this is just perfect, thanks for the explanation

  • @natesr5373
    @natesr5373 3 месяца назад

    Get truncated is the word I'm looking for. Thanks Bro Code. nice video

  • @mariaangeldas1554
    @mariaangeldas1554 16 дней назад

    Thank you Bro Code. U saved me for my quiz

  • @Mathieuny
    @Mathieuny 5 месяцев назад

    Thanks for the video. Very understandable, good to get me started :)

  • @Raphamerlo
    @Raphamerlo 3 месяца назад

    Thank you. I perfectly understood.

  • @prumchhangsreng979
    @prumchhangsreng979 2 года назад +4

    I'm grateful that I didn't skip binary in high school math class.

  • @CoffeeDump
    @CoffeeDump 5 месяцев назад

    i finally know what this operators means, thanks.

  • @Abon963
    @Abon963 Год назад

    Thanks!You made it very much easier

  • @pemudahijrah2454
    @pemudahijrah2454 11 месяцев назад +25

    So bassically 12&6 is equal to 6&12 is it?

    • @Vishnu-wz5ng
      @Vishnu-wz5ng 10 месяцев назад

      Yes

    • @Smexyman0808
      @Smexyman0808 Месяц назад +1

      It's a logic operator; There is no left and right.

  • @Jaimin_Bariya
    @Jaimin_Bariya 2 месяца назад

    Jp Here,
    Thank you :)

  • @ansoncheng6418
    @ansoncheng6418 6 месяцев назад

    Thank you for this

  • @sais640
    @sais640 11 месяцев назад

    thanks bro code for the helpful tips :) and to everyone have fun programming

  • @jacksoncobb2860
    @jacksoncobb2860 Год назад

    Super helpful video! Thank you!

  • @usurpvision
    @usurpvision 9 месяцев назад

    Ok cool thanks my reference book did not explain shifts very well.

  • @MonirsOfficial
    @MonirsOfficial 10 месяцев назад

    Masterpiece❤

  • @ironmonkey1990
    @ironmonkey1990 4 месяца назад

    Thank you!

  • @dredogu06
    @dredogu06 2 года назад +1

    Thanks bro

  • @BARATHBSIT
    @BARATHBSIT 3 года назад

    Your a real programmer 😎

  • @itsrmbaby
    @itsrmbaby 9 месяцев назад

    شكرا

  • @cd-stephen
    @cd-stephen 2 года назад

    Bro!!!!! You are awesome and thank you

  • @rydinorwin
    @rydinorwin 20 дней назад

    Perfect!

  • @mortenlund1418
    @mortenlund1418 Год назад

    thx and great style

  • @lizisichinava6733
    @lizisichinava6733 2 месяца назад

    TYSM

  • @Dexterdevloper
    @Dexterdevloper 8 месяцев назад

    Thanks.

  • @YohayShabtiev
    @YohayShabtiev Год назад

    BIG LIKE!

  • @aymanmouhcine5749
    @aymanmouhcine5749 Год назад

    Thank you

  • @abdoumourouj6551
    @abdoumourouj6551 3 месяца назад

    huge respect

  • @indigo_diary
    @indigo_diary Год назад

    Thank you so much :)

  • @thatonemailbox
    @thatonemailbox Год назад +5

    What kinds of uses do these commands have?

    • @Abon963
      @Abon963 Год назад +4

      One use is : It can be really fast for calculations

    • @SoDamnMetal
      @SoDamnMetal 11 месяцев назад

      @@Abon963 so, something the compiler would automatically optimize for you?

    • @Exploshi
      @Exploshi 9 месяцев назад

      to quickly find if a number is a power of two you can do "return n>0 and n&(n-1)"

    • @P_Ahmed_P
      @P_Ahmed_P Месяц назад +2

      When you promote a friend to admin in a Facebook group, you can assign them certain permissions, which control what they can do in the group. These permissions are typically represented as a series of options, each with a corresponding value, like this:
      Option 1: Approve posts (value: 1)
      Option 2: Delete posts (value: 2)
      Option 3: Pin posts (value: 4)
      Option 4: Manage members (value: 8)
      Permissions can be combined using a binary system. For example, if you give your friend a permission value of 5, you’re essentially giving them a combination of options 1 and 4. In binary, 5 is represented as 00000101, where the 1s correspond to the permissions you've enabled.
      To check if a certain permission is included, you can use the bitwise AND (&) operator. If you want to check whether they have permission for a specific option, you can perform the AND operation between the permission value and the option's value. For example, checking if option 1 (value 1) is enabled for a permission value of 5 would look like this:
      5 & 1 = 1 (True, they have permission)
      5 & 2 = 0 (False, they don’t have permission)
      5 & 4 = 4 (True, they have permission)
      This way, you can easily determine which specific permissions are granted using a single number.

  • @MiyamotoMusashi23839
    @MiyamotoMusashi23839 3 месяца назад

    thx buddy

  • @Darkin-w
    @Darkin-w 10 месяцев назад

    Ty :)

  • @SaiTaX_the_Chile_boi
    @SaiTaX_the_Chile_boi Месяц назад

    bro code the goat.

  • @ar_felix
    @ar_felix Месяц назад

    what is complex about the complement operator? it seems it just inverts 0 to 1 and 1 to 0

  • @_4p_
    @_4p_ Год назад +3

    where is ~ (complement operator)

  • @bowa
    @bowa 10 месяцев назад

    King!

  • @Aufrichtig-und-wichtig
    @Aufrichtig-und-wichtig 6 дней назад

    legend.

  • @113_bachtiardanuarta_b2
    @113_bachtiardanuarta_b2 Год назад

    Simple yet easy to understand

  • @hemozone9726
    @hemozone9726 Год назад

    thanks man

  • @Thundergreen-lj2ot
    @Thundergreen-lj2ot 5 месяцев назад

    Is it just me who noticed the text size change as the first change?

  • @kevingerges9539
    @kevingerges9539 9 месяцев назад

    for xor , 1 OR 1 = 1: If both bits are 1, the result is , how come 1 and 1 is zero

    • @zakd6768
      @zakd6768 5 месяцев назад

      X is for exclusive. Think of OR as being ok with AND.
      1 OR 1 = 1
      1 OR 0 = 1
      Because AT LEAST 1 is 1. So OR doesn't mind both being 1.
      1 XOR 1 = 0 Because AT MOST should be 1. Break it into human speech and it becomes easier.
      True is 1 and false is 0
      a XOR b = if exclusively one operand is true, return true. Else return false.
      AND =BOTH
      OR =AT LEAST 1
      XOR =AT MOST 1

  • @trantung8474
    @trantung8474 29 дней назад

    1:25

  • @mahmoudalfawair2967
    @mahmoudalfawair2967 2 года назад +5

    giga big coc chad thx

  • @Lucky_Wings
    @Lucky_Wings 5 месяцев назад

    yeah i completely forgot it

  • @naveenkumar1853
    @naveenkumar1853 11 месяцев назад

    Hello

  • @fedorvasilev5883
    @fedorvasilev5883 Год назад

    Why do you use %d ?

    • @atheist9672
      @atheist9672 10 месяцев назад

      It is an format specifier it this time you know what is that....I hope you know😅😅😅😅

  • @Jesusiskingbroo
    @Jesusiskingbroo 2 года назад

    Robert

  • @motasam8122
    @motasam8122 Год назад

    try 100

  • @mastersrv470
    @mastersrv470 2 года назад +1

    Thanks bro

  • @nattyzaddy6555
    @nattyzaddy6555 Год назад

    Thanks bro