MMGames Introduction to C C Language Development Environment C language now Useful Apps Contact Us

Automatic version identification


It's easy to tell by looking at it.

Response Time Checker

I can leave my computer on and do it.

Mouse cleaning time

I can leave my computer on and do it.

Mouse cleaning time

C language learned by suffering
C language learned by suffering

Type of value

Various numbers
So far, we have used the expression "numerical value.
There are two types of numbers handled by the C language.
They are integers and real numbers.

An integer is a natural number plus zero and a negative number.
For example, 1, -1, 0, 5, 8, 7... and so on.
In short, the ordinary numbers we normally use are called integers.

A real number is an integer plus a fractional number.
For example, 1.0, 5.2, -9.687, 3.14159, and so on.
In short, a number that contains decimals is called a real number.

Also, integers can be written in three different ways.
It is divided into three types: decimal, octal, and hexadecimal.

Format decimal number
Numerals Decimal
0 digit octal
0x number Hexadecimal

Numbers without leading zeros are treated as decimal numbers.
For example, 100, 25, 68, 71, 19023, etc. are decimal numbers.

Numbers with leading zeros are treated as octal numbers.
For example, 0152, 027, 0756, 030303, etc. are octal numbers.
In the ordinary sense, one would think that 0152 and 152 are the same number.
Note that in C, 0152 is interpreted as an octal number (106 in decimal).

Also, for the same reason, numbers such as 089, say, are an error in C.
This is because octal numbers do not use numbers like 8 or 9.

In reality, octal numbers are rarely used, so it is better not to add leading zeros.
Incidentally, there is no problem if the number is set to 0, since it is also 0 in octal.

Surprisingly often used are hexadecimal numbers, which are represented by a leading 0x.
For example, 0xFF, 0xA7, 0x912C, 0xABCD, etc. are hexadecimal numbers.
In C, the representation of a number with a specific meaning, such as a character code, is represented by a
In addition to the customary use of hexadecimal numbers, the
Hexadecimal notation is frequently used for bit operations and other processes.
Of course, beginners are not likely to use it for the time being.

Note that only decimal numbers can be used to represent real numbers.
There are many ways to handle real numbers on a computer.
The C language uses a method called floating point method.
For this reason, real numbers are often referred to as floating decimals in the C language world.

Floating point method

A method of expressing a real number in terms of a sequence of numbers (the mantissa part) and the position of the decimal point (the exponent part).
Real numbers are expressed by multiplying the mantissa part by a value such as a power of 10.
This method is convenient for handling both large and very small numbers, but it is slow.

Computing Real Numbers
The calculation we did in the previous chapter gave the answer 10/3 (10 divided by 3) as 3.
I would like to calculate this as accurately as possible using real numbers.
However, since it is not a fraction, it cannot be calculated with perfect accuracy. Please forgive me.

Accurate calculations
As you can see, it is difficult to perform exact calculations on a computer.
When real numbers are used, there will always be some numbers that are not divisible.
There is also an error caused by the use of binary numbers.
In fact, binary numbers cannot accurately represent numbers such as 0.1.

Under normal circumstances, rounding off the rounded numbers would not be a big problem.
Bank computers, for example, which need to be accurate, are
They have a mechanism to calculate as a decimal fraction.

If you want to calculate with real numbers, just make the number a real number and it will automatically be calculated as a real number.
That's fine for the calculation itself, but there's one more thing to keep in mind.
The output conversion specifier used for display will also change.

Previously, when displaying numerical values, the %d specifier has been used.
This is a specifier for converting integer values to numbers.
If you want to convert a real number to a numeric value, you must use the %f specifier.

Once you know this much, the rest is easy.
The following program is an example of a program from the previous section reworked into a calculation using real numbers.

source code
 #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 result of executing this program will be as follows

Execution Result

The answer is very much like a calculation with real numbers.
Note that the % (remainder) operator is not used this time, but this is to be expected.
Since the remainder cannot be calculated with real numbers, the % operator cannot be used.

About this Site

The C language (bitter C), which is learned by suffering, is
This is the definitive C language introductory site.
It systematically explains the basic functions of the C language and
It is as complete as or more complete than any book on the market.

Part 0: Program Overview
  1. What is the program?
Chapter 2: How to write a program
  1. Writing Rules
  2. Writing conventions
  3. Exercise 2
Chapter 3: Display on Screen
  1. String display
  2. newline character
  3. Exercise 3
Chapter 4: Numeric Display and Calculation
  1. Numeric Display
  2. Basic Calculations
  3. Type of value
  4. Exercise 4
Chapter 5: Numerical Memory and Calculation
  1. Memorize values
  2. Variable Type
  3. Type conversion
  4. Numeric justification
  5. Exercise 5
Chapter 6: Input from the keyboard
  1. Functions for input
  2. Fear of Input
  3. Exercise 6
Chapter 9: Repetition with a fixed number of times
  1. Sentences that repeat themselves
  2. Loop Operation Mechanism
  3. Exercise 9
Chapter 10: Unknown number of repetitions
  1. Loop of unknown frequency
  2. input check
  3. Exercise 10
Chapter 13: Handling Multiple Variables at Once
  1. Multiple variables are handled together.
  2. How to use arrays
  3. Exercise 13
Chapter 19: Dynamic Arrays
  1. Create arrays at will
  2. Exercise 19
Chapter 20: Multiple Source Files
  1. Minimal division
  2. The Stone of Partition
  3. Exercise 20


Open the 💬 comment submission box