如果有下个小数,位数比较长,问用什么方法使他的小数位 限定在一个值里,(10分)

  • 主题发起人 主题发起人 晨空
  • 开始时间 开始时间

晨空

Unregistered / Unconfirmed
GUEST, unregistred user!
如果有下个小数,位数比较长,问用什么方法使他的小数位 限定在一个值里,
比如,有小数5632.123456789 怎么样使他变 成 5632.12?
 
RoundTo
Rounds a floating-point value to a specified digit or power of ten using
揃anker抯 rounding?
Unit
Math
Category
Arithmetic routines
type TRoundToRange = -37..37;
function RoundTo(const AValue: do
uble;
const ADigit: TRoundToRange): do
uble;
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.
 
使用FORMAT函数
 
使用以下算式:
round(5632.123456789*100)/100.0
想保留n位就用10^n乘扣除
 
后退
顶部