I use Borland C++ 4.5, I just discovered, there's wrong with it or bug.
Simple example:
#include<stdio.h>
#include<conio.h>
void main(void)
{
int ctr, y = 0;
float num2 = 0.000000;
for(ctr = 1; ctr < 21; ctr++)
{
if((y >= 0) && (y <= 2))
{
gotoxy(4,22+y);
if((num2 == 0.0) || (num2 == 0.5) || (num2 == 1.0))
printf("Good! %f is accurate, there's no extra or less decimal number........", num2);
else
printf("Bad! %f isn't accurate, maybe there's extra or less decimal number...", num2);
y++;
if(y == 3)
{
gotoxy(51,22+y);
printf(". .. ........like 0.00...01!");
}
}
gotoxy(1,ctr);
printf("%f\t", num2);
num2 += 0.1;
gotoxy(17,ctr);
printf("%f\t", num2);
num2 += 0.1;
gotoxy(33,ctr);
printf("%f\t", num2);
num2 += 0.1;
gotoxy(49,ctr);
printf("%f\t", num2);
num2 += 0.1;
gotoxy(65,ctr);
printf("%f\n", num2);
num2 += 0.1; //Even if you try write 0.100000, it's useless 0.100000 == 0.1.
} //Same in 0.01 or 0.001 and so on is still have common problem.
}
- #include<stdio.h>
- #include<conio.h>
-
- void main(void)
- {
- int ctr, y = 0;
- float num2 = 0.000000;
-
- for(ctr = 1; ctr < 21; ctr++)
- {
- if((y >= 0) && (y <= 2))
- {
- gotoxy(4,22+y);
- if((num2 == 0.0) || (num2 == 0.5) || (num2 == 1.0))
- printf("Good! %f is accurate, there's no extra or less decimal number........", num2);
- else
- printf("Bad! %f isn't accurate, maybe there's extra or less decimal number...", num2);
- y++;
- if(y == 3)
- {
- gotoxy(51,22+y);
- printf(". .. ........like 0.00...01!");
- }
- }
- gotoxy(1,ctr);
- printf("%f\t", num2);
- num2 += 0.1;
- gotoxy(17,ctr);
- printf("%f\t", num2);
- num2 += 0.1;
- gotoxy(33,ctr);
- printf("%f\t", num2);
- num2 += 0.1;
- gotoxy(49,ctr);
- printf("%f\t", num2);
- num2 += 0.1;
- gotoxy(65,ctr);
- printf("%f\n", num2);
- num2 += 0.1; //Even if you try write 0.100000, it's useless 0.100000 == 0.1.
- } //Same in 0.01 or 0.001 and so on is still have common problem.
- }
-
****************************************
**If you try to check the watch the result is this:**
_____________________________________________
****************************************
*****+Process Of+*****++Incrementing of 0.1++**
*****+++num++++*****++++++++++++++++++**
****************************************
..................0.0 - 0.7..................
.........0.8000001 - 0.9000001........
..................1.0 - 2.7..................
..........2.799999 - 3.799999..........
..........3.899998 - 5.099998..........
..........5.199997 - 6.099997..........
..........6.199996 - 7.199996..........
..........7.299995 - 8.299995..........
..........8.399996 - 8.499996..........
..........8.599997 - so on... ...........
..........and so far..... ...................