【发布时间】:2012-05-17 21:31:28
【问题描述】:
所以 resizeWidth 和 resizeHeight 是以下代码中的 numericUpDown 控件。 此外,tempBitmapW 和 tempBitmapH 都是浮点数。
float rW = (float)resizeWidth.Value;
float rH = (float)resizeHeight.Value;
rH = (float)Math.Truncate(tempBitmapH * ((float)rW / tempBitmapW));
int rsW = (int)rW;
int rsH = (int)rH;
resizeWidth.Value = rsW;
resizeHeight.Value = rsH;
现在,当我调试它时,rsW 和 rsH 以及 rW 和 rH 不会读为 0,它们都没有。 但由于某种原因,numericUpDown 控件会抛出错误,因为值 0 超出了最小值/最大值范围(最小值设置为 1),因此基本上它会将其读取为 0。
我做错了什么?
【问题讨论】:
-
tempBitmapH、resizeWidth.Value和resizeHeight.Value的原始值是多少?
-
你确定 rsW 和 rsH 大于 0 吗?这不是正常行为。
标签: c# floating-point int numeric