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: -
--------------------------
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:
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();
}
//---------------------------------------------------------------------------