MENU

Fun & Interesting

I Wrote An “Impossible” Bug in a C Program. THIS is How I Fixed It.

Code With Huw 2,830 6 months ago
Video Not Working? Fix It Now

Well, it seemed impossible at first sight. There was a test on a value that I had predefined so I knew it must be true. And yet the test failed. WHY??? To understand this problem in more depth, you need to understand how numbers and other data types are represented at a fairly low level. If this is new to you, or if you are uncertain about the finer details, I suggest you watch these videos: Bits, Bytes and Binary Numbers https://youtu.be/FD6m-5iNWqI?si=na5MaCmdqAUJywBG What is a Binary Number? https://youtu.be/8-usRf9if-8?si=2i2pHUpWIDNKer0y Signed and Unsigned Numbers https://youtu.be/aHvHKv9BTZg?si=bHprWcM4tnY5MU51 Why Do Big Numbers Turn Negative? https://youtu.be/LTCS8UMjJOA?si=8M1e9aVol1rqKTPD MORE LESSONS ============= To watch other videos about “low level programming”, go to the “Down To The Metal” playlist: https://www.youtube.com/playlist?list=PLZHx5heVfgEt8Ynevr3OX9UBKLPXdSMGM Also, my series on “Programming C in Visual Studio”: https://www.youtube.com/playlist?list=PLZHx5heVfgEvL826uk3DeeUy1QiP7nrIs Be sure to subscribe to the Code With Huw channel so that you get a notification when I upload more lessons in this series. PROGRAMMING BOOKS ==================== If you want to learn programming in more depth (and also support this channel!) you might think of buying one of my books. I have written books on C programming, Using Pointers in C, Recursion and other programming topics. You can buy my books (paperback or Kindle) on Amazon. *** The Little Book Of Pointers *** Amazon (US) https://amzn.to/2LF2aVb Amazon (UK) https://amzn.to/2FViSvS *** The Little Book Of C Programming *** Amazon (US) https://amzn.to/2RXwA6a Amazon (UK) https://amzn.to/2JhlwOA “CODE WITH HUW” ON TWITTER: ================================= https://twitter.com/codewithhuw “CODE WITH HUW” ON FACEBOOK: ================================= https://www.facebook.com/CodeWithHuw Good luck! And good programming!

Comment