关于round的问题:(100分)

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

silverwolf

Unregistered / Unconfirmed
GUEST, unregistred user!
今天我编了个程序发现一个奇怪的现象:
round(1/2)=0
round(3/2)=2
round(5/2)=2
round(7/2)=4
round(9/2)=4
为什么会出现这样的结果?到底round是不是根据四舍五入来取整?
 
round是取最接近它的整数,四舍五入用trunc
 
怎么可能呢 ?
Round 是四舍五入,Trunc是取整数部分!
 
Round returns an Int64 value that is the value of X rounded to the nearest
whole number. If X is exactly halfway between two whole numbers, the result
is always the even number. This method of rounding is often called
揃anker抯 Rounding?
The Trunc function truncates a real-type value to an integer-type value. X
is a real-type expression. Trunc returns an Int64 value that is the value
of X rounded toward zero.
看看吧,Help里面的。
 

CJF写的对,应该多看帮助,可以结束给分了。
你不结束,过两天我就结束它了!
 
接受答案了.
 

Similar threads

S
回复
0
查看
650
SUNSTONE的Delphi笔记
S
顶部