VC++科学计算器设计源代码及流程图 第2页
单目运算符的实现void CJSQDlg::On_Xpingfang()
{
newinput=TRUE;
UpdateData(true);
if (m_vfront.GetLength()>30){
MessageBox("为了保证数据能显示完整,及数据不溢出,请你不要计算这么大的数据!\n现在数据位数已经超过30位了!");
}
float temp=atof(m_vfront)*atof(m_vfront);
m_vfront.Format("%f",temp);
m_vfront.TrimRight("0");
m_vfront.TrimRight(".");
UpdateData(FALSE);
}
进制转换的实现:
void CJSQDlg::On_Erjinzhi()
{
int tmp;
float m;
char datacoverttemp[100];
newinput=TRUE;
if(datakind!=10)
m=coverttofloat(m_vfront,datakind);
else
m=atof(m_vfront);
tmp=int(m);
datakind=2;
_itoa(tmp,datacoverttemp,2);
m_vfront.Format("%s",datacoverttemp);
UpdateData(FALSE);
}
void CJSQDlg::On_shijinzhi()
{
int tmp;
float m;
char datacoverttemp[100];
newinput=TRUE;
if(datakind!=10)
m=coverttofloat(m_vfront,datakind);
else
m=atof(m_vfront);
tmp=int(m);
datakind=10;
m_vfront.Format("%f",m);
m_vfront.TrimRight("0");
m_vfront.TrimRight(".");
UpdateData(FALSE);
}
三角函数计算的实现:
void CJSQDlg::On_sin()
{
newinput=TRUE;
if(jiaodu==1)
{
UpdateData(true);
float temp=sin(atof(m_vfront));
m_vfront.Format("%f",temp);
m_vfront.TrimRight("0");
m_vfront.TrimRight(".");
}
else if(jiaodu==0)
{
float temp=sin(atof(m_vfront)*pi/180);
m_vfront.Format("%f",temp);
m_vfront.TrimRight("0");
m_vfront.TrimRight(".");
}
else
{
float temp=sin(atof(m_vfront)*pi/200);
m_vfront.Format("%f",temp);
m_vfront.TrimRight("0");
m_vfront.TrimRight(".");
}
UpdateData(FALSE);
}669