hi@all,

ich programmiere gerade einen taschenrechner in borland und möchte gerade ein komma-button machen. also wenn ich 1,1 + 1,1 rechne, kommt da 2,20000004768372 heraus. aber wenn ich z.b. 2,5 * 2,9 rechne kommt das korrekte ergebnis 7,25 heraus. wie kann das kommen?

danke im vorraus.

::: smista :::
--------------------------
hier mein code: -
--------------------------
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
void __fastcall TForm1::Button1Click(TObject *Sender)
{
 strcat(anzeige, "1");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::Button2Click(TObject *Sender)
{
strcat(anzeige, "2");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
strcat(anzeige, "3");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
strcat(anzeige, "4");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
strcat(anzeige, "5");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
strcat(anzeige, "6");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
strcat(anzeige, "7");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
strcat(anzeige, "8");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
strcat(anzeige, "9");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button10Click(TObject *Sender)
{
strcat(anzeige, "0");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button12Click(TObject *Sender)
{
 y = StrToFloat(Edit1->Text);
 if(Taste == 1) z = x + y;
 if(Taste == 2) z = x - y;
 if(Taste == 3) z = x * y;
 if(Taste == 4) z = x / y;
 Edit1->Text = FloatToStr(z);
 strcpy(anzeige,"");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button13Click(TObject *Sender)
{
 x = StrToFloat(Edit1->Text);
 Taste = 1;
 strcpy(anzeige,"");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button14Click(TObject *Sender)
{
x = StrToFloat(Edit1->Text);
 Taste = 2;
 strcpy(anzeige,"");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button15Click(TObject *Sender)
{
 x = StrToFloat(Edit1->Text);
 Taste = 3;
 strcpy(anzeige,"");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button16Click(TObject *Sender)
{
 x = StrToFloat(Edit1->Text);
 Taste = 4;
 strcpy(anzeige,"");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11Click(TObject *Sender)
{
 strcpy(anzeige,"");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button17Click(TObject *Sender)
{
 strcat(anzeige, ",");
 Edit1->Text = anzeige;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button18Click(TObject *Sender)
{
 Application->Terminate();
}
//---------------------------------------------------------------------------