Because the char are all represented by a number and ‘0’ is the first of them all.
On the table below you see that:
'0' => 48
'1' => 49
'9' => 57.
As a result: ('9'
– '0'
) = (57 − 48) = 9
Source: http://www.asciitable.com
More Related Contents:
- Efficient way to determine number of digits in an integer
- C++ – how to find the length of an integer
- Are the character digits [‘0’..’9′] required to have contiguous numeric values?
- Set the digits after decimal point
- Expected { at the end of output
- C++ Socket Error (new initializer expression list treated as compound expression)
- How is “=default” different from “{}” for default constructor and destructor?
- How do I sort a vector of pairs based on the second element of the pair?
- Is main() really start of a C++ program?
- multiple definition in header file
- How do you find what version of libstdc++ library is installed on your linux machine?
- What are the pitfalls of ADL?
- Making operator
- Is there a production ready lock-free queue or hash implementation in C++ [closed]
- Select class constructor using enable_if
- Static member access in constant expressions
- Understanding stack frame of function call in C/C++? [closed]
- Are int8_t and uint8_t intended to be char types?
- Double alignment
- Cannot create constexpr std::vector
- How do YOU reduce compile time, and linking time for Visual C++ projects (native C++)?
- Correct usage of the Eigen::Ref class
- Possible causes for Boost not being found by CMake in certain situations?
- What is the most efficient way to display decoded video frames in Qt?
- Incomplete class usage in template
- Default member values best practice
- How to increase error limit in Visual Studio?
- Is the comma in a variable list a sequence point?
- return 0 implicit
- Why do I need to repeat template arguments of my base class in member initalizer list?