※スタイルシート未対応ブラウザではレイアウトを正確に再現できません。
> | advanced by | contents  | that returns in <
< [modosusu] > Color magazine monochrome light and shade   font predetermined, Gothic Ming-style type longhand   size Konaka large   standard

Kind of numerical value

1. ..clause 1..: Various numerical values
2. ..clause 2..: Calculation of real number

[1] Various numerical values

Though the expression of numerical value has been used for the unit up to now
Two kinds of numerical values treated by C language exist.
It is an integer and a real number.

The integer is a number in which 0 and a negative number were added to the natural number.
It is a number such as 1 and 1, 0, 5, 8, and -7 for instance ･･･.
In short, we are usually using, and a usual number is called an integer.

The real number is a number in which the decimal value was added to the integer.
For instance, it is the numbers such as 1.0, 5.2, and 9.687 and -3.14159.
In short, the number including the decimal is called a real number.

Moreover, the integer can use three kinds of writing.
It has divided into three kinds (the decimal number, the octal number, and the hexadecimal number).
 Format -adic number Figure Decimal number 0 figures Octal number 0x figure Hexadecimal number
The number in which 0 is not applied to the head is treated as a decimal number.
100, 25, 68, 71, and 19023 for instance etc. It is a decimal number.

The number in which 0 is applied to the head is treated as an octal number.
0152,027, 0756, and 030303 for instance etc. It is an octal number.
In a usual sense, 0152 also : Though it is thought that 152 is the same number
In C language, it is necessary to note it because 0152 is interpreted as the octal number (It is 106 in the decimal number).

Moreover, it makes an error of the number called 089 by a similar reason in C language.
Because 8 in the octal number The reason for the figure called nine is that it doesn't use it.

Actually, to the head because it is rare to use the octal number I do not think that you should apply 0.
There is separately no problem because it is By the way, even the octal number : when assuming 0 0.

Being used unexpectedly well is this : in the hexadecimal number to the head It shows applying 0x.
For instance, 0xFF, 0xA7, 0x912C, and 0xABCD, etc. are hexadecimal numbers.
In C language, to the expression of the numerical value of the local meaning like the character-code etc.
Another for whom hexadecimal number might be used in custom
The mark of the hexadecimal number is frequently used in the processing of the bit operation etc.
Of course, though beginner's person doesn't think that he or she will use it for the present.

Only the decimal number can be used for the mark of the real number.
Though there is variously method of treating the real number with the computer
The method of calling the floating decimal point arithmetic for C language is used.
Therefore, there is what calls the real number a floatage decimal in the world of C language well.

[   Floating decimal point arithmetic   ]
Method of showing real number value at position of row of numerical value (mantissa) and decimal point (exponent part).
The power etc. of the value of ten how many are expressed in the mantissa, and it multiplies and the real number is expressed.
The calculation is slow though it can treat from a huge number to a minimum number and is convenient.

[2] Calculation of real number

In the calculation done in the preceding chapter, the answer of 10/3(10÷3) has been gotten with three.
I want to calculate this by using the real number as accurately as possible.
However, because it is not a fraction, it is not possible to calculate perfectly and accurately. Pardon it.

[   Correct count   ]
It is difficult to do an accurate calculation with the computer in this manner.
Besides the number that must be not able to be divided is generated if you use the real number
There is an error margin that occurs because it calculates by the binary number, too.
- Actually, in the binary number The numerical value such as 0.1 cannot be shown accurately.
Though it doesn't become a major issue in case of the half-adjust if usual
The computer etc. of the bank where accuracy is necessary
Seem to have the mechanism calculating as a fraction of the decimal number.
If the numerical value is made a real number to calculate by the real number, it automatically becomes a calculation of the real number.
The calculation : as another notes in it though they are unquestionable.
An output conversion finger fixed child who uses it when displaying it changes, too.

Though %d finger fixed child had been used up to now when the numerical value was displayed
This is a finger fixed child to convert the integral value into the figure.
When the real number value is converted into the figure, it is not possible to do if %f finger fixed child is not used.

It is easy now if it understands here.
As for the program of the preceding chapter, the following program is a mending example to the calculation by the real number.

```
#include <stdio.h>

int main(void)
{
printf("%f\n",10.0 + 3.0);
printf("%f\n",10.0 - 3.0);
printf("%f\n",10.0 * 3.0);
printf("%f\n",10.0 / 3.0);
return 0;
}
```
The execution result of this program becomes as follows.

13.000000
7.000000
30.000000
3.333333
It became an answer of the feeling said the calculation really by the real number.
This is natural though %(surplus) operator is not used this time.
Because it is not possible to calculate, % operator cannot be so used by the real number.

It returns to contents.

< - It is advanced -> | in | head that returns  to returning  next |.