浮点数的转换问题:在线等待) (50分)

  • 主题发起人 savetime
  • 开始时间
S

savetime

Unregistered / Unconfirmed
GUEST, unregistred user!
pt: TPoint;
FontWidth: Integer;
cxDpi: Single

为何以下语句不能编译(D5),提示无效类型转换

pt.x := Integer(FontWidth * cxDpi / 72);
 
pt.x := Trunc(FontWidth * cxDpi / 72);
 
pt.x := Int(FontWidth * cxDpi / 72);
 
cxDpi:Integer;

pt.x := round(FontWidth * cxDpi / 72);
 
将FontWidth转换成float型计算
delphi的好像没有强制转换的功能,必须自己做!!
 
如果想四舍五入 可以用chuguozhen, 的法子

如果只舍不入 可以先 int 后 round 即

pt.x := round(Int(FontWidth * cxDpi / 72));
 
咦,我记得已经结束本贴了?
 
顶部