请问在DELPHI里面有什么function可以直接将一个Double类型的数字转化为固定小数位数。(不引入字符串转换,仅用一个function)(50分)

  • 主题发起人 主题发起人 hyesheng
  • 开始时间 开始时间
H

hyesheng

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在DELPHI里面有什么function可以直接将一个Double类型的数字转化为固定小数位数。(不引入字符串转换,仅用一个function)
 
function RoundTo(const AValue: Double
const ADigit: TRoundToRange): Double;

Description

Call RoundTo to round AValue to a specified power of ten.

AValue is the value to round.

ADigit indicates the power of ten to which you want AValue rounded. It can be any value from ?7 to 37 (inclusive).

RoundTo uses 揃anker抯 Rounding?to determine how to round values that are exactly midway between the two values that have the desired number of significant digits. This method rounds to an even number in the case that AValue is not nearer to either value.

The following examples illustrate the use of RoundTo:

Expression Value

RoundTo(1234567, 3) 1234000
RoundTo(1.234, -2) 1.23
RoundTo(1.235, -2) 1.24
RoundTo(1.245, -2) 1.24

Note: The behavior of RoundTo can be affected by the Set8087CW procedure or SetRoundMode function.

ype TFPURoundingMode = (rmNearest, rmDown, rmUp, rmTruncate);
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;

Description

Call SetRoundingMode to specify how the FPU handles rounding issues. The rounding mode can be any of the following values:

Value Meaning

rmNearest Rounds to the closest value.
rmDown Rounds toward negative infinity.
rmUp Rounds toward positive infinity.
rmTruncate Truncates the value, rounding positive numbers down and negative numbers up.
 
我的机器怎么没有这东东?
 
有?????
 
hehe, uses 了 Math 就有了
 
后退
顶部