A
A
alex4answ2019-08-06 11:46:55
Programming
alex4answ, 2019-08-06 11:46:55

Why use the hexadecimal number system?

Good afternoon, I'm scrolling through the github, and I see that sooo many programmers use the hexadecimal number system.
Sometimes it's clear why. For example, when the error code is 970 (10), it's easier to write 3CA(16)), it's just convenient and understandable.
BUT, for example, when small numbers are converted to a hexadecimal system, I don’t understand this.
For example, constants:

const OP_INSERT = 0x01;
const OP_UPDATE = 0x02;
const OP_DELETE = 0x04;

etc., wouldn't it be easier and more understandable to write in the decimal number system?
Please tell me why and why is it used?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2019-08-06
@alex4answ

Because it easily falls on the binary number system, and each byte appears as two digits.
And such data is usually meaningless in the decimal system.

P
pfg21, 2019-08-06
@pfg21

Clause 1 so that everything is uniform, albeit ugly.
Imagine records of numbers of the 16th format and numbers of the 10th format will randomly alternate. there is a high probability that a person will make a mistake and write down the number not as it should be.
on the other hand, this is just a human-readable text, you can also write "decimal" numbers. the compiler doesn't care about that.
until you get into a team with strict adherence to paragraph 1 :) there and not on such a stretch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question