Numbers
Number is an abstract unit of measure for quantity.
1
, 2
, 1888
, 712.4
are all numbers.
-7
is also a number. Although in most programming languages there is no literal notation.
A number is a value. It has neither a unit of measure nor a number system. Strictly speaking, one cannot even say that it consists of numbers.
Numbers within a programming language
To what is said above, the data type is added, as well as the possibility of a literal notation.
In memory, the number is represented by a certain set of binary data. No need to say that in this piece of memory are hexes. These are just bytes and bits. A hex dump of a piece of memory is a dump, but not a number.
For example, for C:
10
, 012
, 0xa
, 0x0A
are different entries of the same number.10
, 10L
, 10.0
are different (albeit equal) numbers, because they have different data types. Of course, they can be considered to be the same, if the value is important for us, not type, but from the point of view of the compiler they are different.
Number systems
The number can be represented as a string in different number systems.
This is still the same number, but the string representations are different.
"1111111111"
, "1010"
, "14"
, "A"
are all representations of the number 10 in different number systems (unary, binary, hexadecimal and hexadecimal, respectively).
The phrase "a number in hexadecimal numbering system " is correct, but implicitly implies a " textual representation of a number in hexadecimal numbering system ", i.e., we are talking about a string, not a number.
Numbers
A letter is one character in a word, and
A digit is a single character in the string representation of a number (decimal by default).
A digit can imply both a string ( "5"
, "A"
), and a numeric ( 5
, 10
) variant.
The string variant is the output character, whereas the numeric character should be considered as a remainder in the residue ring.
Arithmetic operations on numbers cannot be performed.
The phrase "add numbers 5 and 7" is incorrect, you can only add numbers.
However, in some cases implicit interpretation of numbers as numbers is possible.
Numbers figures
If the number system is not specified, then decimal is implied.
By numbers, numbers are usually meant the numerical meaning of numbers.
That is, the digits of a number are the set of residues in the residue ring at the base of the number system, which, when scalar multiplied by the corresponding degrees of the number system (already outside the ring), will give the original number. By default, this set is ordered.
In this context, one can speak of arithmetic operations, for example, the " sum of digits of a number " is the sum of the numbers of the above set. Since we are already talking about numbers, the number system no longer plays a role - it was only needed to get a set.
Numbers in string context
A number is any character that belongs to the corresponding category of unicode.
We can assume that it is used to write numbers in natural languages (programming languages do not fit: in writing, 0xA
- the symbol A
used as a number, but in reality it is a letter). At the same time, I cannot say with an absolute guarantee that any Unicode digit is used in at least one natural language.
PS: In most cases, integers are meant above, but a similar interpretation is possible for fractional ones.