C#比较float到int

时间:2010-10-01 02:01:09

标签: c# floating-point windows-mobile compact-framework

我看到这些代码在intertubes上浮动,用于确定Windows Mobile设备是否具有VGA屏幕(代码位于Form类的方法中):

SizeF currentScreen = this.CurrentAutoScaleDimensions;
bool isVGA = currentScreen.Height == 192;

即使屏幕是VGA因为浮点不精确(高度属性是浮点数),isVGA是否可能设置为false?

1 个答案:

答案 0 :(得分:4)

不在您提供的示例中,因为(符合IEEE 754,32位)浮点数can accurately represent all integers (whole numbers) whose absolute value is less than or equal to 2^24