De nuevo estoy aquíEscribe este código y comprueba el funcionamiento. Verás la diferencia entre float y double
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
double Numero1d,Numero2d,Multiplicaciond;
float Numero1f,Numero2f,Multiplicacionf;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
if (Key==13)
{
Numero1f=atof(Edit1->Text.c_str());
Numero1d=atof(Edit1->Text.c_str());
Edit2->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
{
if (Key==13)
{
Numero2f=atof(Edit1->Text.c_str());
Numero2d=atof(Edit1->Text.c_str());
BotonMultiplicar->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BotonMultiplicarClick(TObject *Sender)
{
Multiplicacionf=Numero1f*Numero2f;
Multiplicaciond=Numero1f*Numero2f;
Edit3->Text=AnsiString(Multiplicacionf);
Edit4->Text=AnsiString(Multiplicaciond);
Edit1->SetFocus();
}
//---------------------------------------------------------------------------