Do I really need to COMPLETELY understand binary?

I’m running through the Learning to program with Haiku book by DarkWyrm for google code-in.
In past, I have always programmed in higher level languages like Python and Java, so I’m a novice in any C based languages.
Is it, in practice, really necessary to completely understand binary to be able to program in C or C++?
I have a basic understanding but I was wondering how in-depth I need to go to be able to program in Haiku.

Cheers

If you mean assembly, no. You wont need it unless you have to go to a low level coding, or need very optimized code.

If you mean binary logic (as in true/false), you would be OK with previous knowledge.

If you mean bit arithmetic (bitshifting, xoring, oring, adding, …) then you might need to understand it for some C/Cpp code.

If you mean binary files, you might need to understand what compilation means, and that it involves the steps of compilation + linkage to generate a executable file for the target OS. Just pointing as this, as you have only experience in non-compiled languages (stated above).

Else… provide more info.

2 Likes

If you mean the binary numbers I’d suggest you understand at least summing, doing products and two-s complement notation.

2 Likes

I’m just learning C/Cpp coding, I’m sorry if that’s not specific enough (still learning). I assume I will use it for application development in the future, and I don’t know how deep I should go.

1 Like

Well you don’t need to be a binary calculator. But you have to understand how logical operators works. You need to understand two-s complement and the problem of the double representation of zero, and so, how negative numbers are represented. Especially if you plan to do low level programming. In general, if you’re young I’d suggest to learn this stuff. Your brain will be thankful in a few years.

2 Likes

Hi,

I would suggest you try moving to the next chapters in the book. If you notice something is unclear about binary math later on, you can always get back to this one.

It seems to be a traditional thing for some reason that every book about programming has to start with a course about binary math, which is largely unused througout the rest of the book.

While you will need it to understand some concepts in C and C++, they are not necessarily things you will find in simple programs. And you will definitely not spend your days doing binary math.

2 Likes

While you will need it to understand some concepts in C and C++, they are not necessarily things you will find in simple programs. And you will definitely not spend your days doing binary math.

Well that’s good news :slight_smile:

There’s really not much to understand in binary. Beyond working with bitmasks and the occasional bit of bit manipulation to avoid some clunky operations in C, there’s really no need to have a grasp of binary or hexadecimal besides how to read a number. Most calculator programs convert between bases. It’s what I use. i trust them more than myself.

When programming, you can work in as high or low level as you want. Although there is always a correct tool for the job. Choose the wrong tool and it’s like trying to fix a watch with a sledgehammer, or move a mountain with tweezers.

I like working with hardware. Low level / bare metal. What I said above is about all I need to know in terms of binary. I can’t read an opcode from a string of 1’s and 0’s or even from hex digits. Decades of hard work by countless people has made modern computers this way. Things can be as simple or as complex as you want. Just go for it and learn as you go.

1 Like