C bitwise operators 🔣

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

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

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

    #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 5 месяцев назад

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

  • @sevanthishekar4379
    @sevanthishekar4379 9 месяцев назад +61

    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 7 месяцев назад +1

      thats cool
      thx man

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

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

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

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

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

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

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

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

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

      you know that the udemy courses have discounts right ?

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

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

  • @keynadaby
    @keynadaby 2 месяца назад +1

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

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

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

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

    wonderfully explained. awesome. You are the real G.

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

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

  • @antoinebguitar2869
    @antoinebguitar2869 10 месяцев назад +4

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

  • @pemudahijrah2454
    @pemudahijrah2454 Год назад +28

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

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

    Amazing explanation. Thank you

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

    Thank you so much! Extremely clear, amazing explanations!

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

    this is just perfect, thanks for the explanation

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

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

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

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

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

    Excellent! Perfect explanation!

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

    Such a good explanation

  • @ar_felix
    @ar_felix 2 месяца назад +1

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

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

    Thank you Bro Code. U saved me for my quiz

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

    Thank you. I perfectly understood.

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

    Jp Here,
    Thank you :)

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

    As someone who is in VLSI design, we do this all the time in Verilog.

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

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

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

    Thanks!You made it very much easier

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

    i finally know what this operators means, thanks.

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

    Super helpful video! Thank you!

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

    What kinds of uses do these commands have?

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

      One use is : It can be really fast for calculations

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

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

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

      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 3 месяца назад +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.

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

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

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

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

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

    Thank you for this

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

    thx and great style

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

    Masterpiece❤

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

    Your a real programmer 😎

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

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

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

    Thanks bro

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

    BIG LIKE!

  • @AbdurRShanto17
    @AbdurRShanto17 19 дней назад

    Thanks man

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

    Thank you so much :)

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

    Perfect!

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

    Thank you!

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

    where is ~ (complement operator)

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

    thanks man

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

    bro code the goat.

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

    thx buddy

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

    Thank you

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

    Thanks.

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

    TYSM

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

    King!

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

    huge respect

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

    شكرا

  • @113_bachtiardanuarta_b2
    @113_bachtiardanuarta_b2 2 года назад

    Simple yet easy to understand

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

    1:25

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

    giga big coc chad thx

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

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

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

      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

  • @Darkin-w
    @Darkin-w Год назад

    Ty :)

  • @Aufrichtig-und-wichtig
    @Aufrichtig-und-wichtig 2 месяца назад

    legend.

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

    Why do you use %d ?

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

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

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

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

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

    yeah i completely forgot it

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

    Hello

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

    Robert

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

    try 100

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

    Thanks bro

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

    Thanks bro