edit1.text:=inttohex(int(SimpleRoundto(10.23,0)),2);
SimpleRoundto(10.23,0)=10没有问题,intohex(10,2)=0A更是没有问题
但是SimpleRoundto是double类型的,所以我用int强制转换,为什么编译错误?
如果这样不行,我应该怎么把double类型转换成int类型?

解决方案 »

  1.   

    var
      s : string; s := floattostr(10.21);
     s := copy(s,1,pos('.',s)-1);
      

  2.   

    但是这样会产生一个问题,Round是四舍六入函数,Round(10.5)=10,而Round(11.5)=12
    这不符合我们常规的四舍五入,常规四舍五入要用simpleroundto,但是simpleroundto又是double类型的,我怎么才能把simpleroundto的double换成int?因为我不想出现Round(10.5)=10这种情况
      

  3.   

    zsjzwj谢谢你说的没错,但是不符合我要求,我要求把一个实数四舍五入成整数,再变成十六进制输出,怎办才好?望指教
      

  4.   

    var
      i:double;
      s:string;i:=10.23;
    inttohex(trunc(i+0.1),2);
      

  5.   

    var
    i:double;
    s:string;i:=10.23;
    inttohex(trunc(round(i+0.1)),2);
    //---回复得太快了。呵~~,改正下
      

  6.   

    我试过了,这样就可以,谢谢各位了
    edit1.Text:=inttohex(trunc(simpleroundto(10.23,0)),2);