如题!
由于看到vb中有Csng,能够将双精度转单精度,不知道vc中是否有类似的函数?

解决方案 »

  1.   

    double b = 2.22
    int x = int(b);
      

  2.   

    double b = 2.22 
    int x = (int)b;
      

  3.   

    就是强制进行类型转换,由于会损失精度,所以要加0.5校正。int x=(int)(b+0.5);
      

  4.   

    还有其他问题就是:当我从编辑框读取含两位小数的数据后(譬如a=atof(m_receive);),a是double型的数,我将a=a*1000以便将两位小数变成整数,接着将a强制转换为long型,最后我想将a的16进制最低两位读出,翻到set【0】中,可是编译的时候,提示出错了:term does not evaluate to a function完整的程序如下:
    double a;
    long b;
    a=atof(m_receive);
    b=long(a*1000);
    set[0]=b;错误出现在set[0]=b;请各位大虾指导!
      

  5.   

    set数组定义如下:
    CByteArray set;
    set.SetSize(10);
      

  6.   

    取最低位:set[0]=b&0x000000FF;