如何获得圆值 [英] How to get round value
问题描述
我正在装箱申请
我想要给定/计算金额的一周。
如果计算的金额是1.2那么它给了1
I am crating one application
I want to round of the given/Calculated amount.
if the calculated amount is 1.2 then it gives 1
Math.Round(95.55)
输出为96
但当我使用
Math.Round时,当计算出的金额大于1.5时显示2
但我想要
输入为1.2然后输出为2
请帮帮我...
提前致谢..
output is 96
but when i use the
Math.Round then it show 2 when the calculated amount is greater than 1.5
but i want
input is 1.2 then output is 2
Please help me...
Thanks in advance..
推荐答案
的正确(已验证)输出当输入 1.2时,Math.Round
是
-
1.0
输入 95.55
The correct (verified) output ofMath.Round
is
1.0
when input is1.2
96
when input is95.55
当输入的值为1.01时,我想要舍入值然后是s如何2
i想要这样..
是否可能
I want round value when the entered value is 1.01 then it show 2
i want like this ..
is it possible
是的,有可能:使用 Math.Ceiling [ ^ ]而不是 Math.Round
。
[/ update]
[update 2]
Yes, it is possible: use Math.Ceiling[^] instead of Math.Round
.
[/update]
[update 2]
我尝试了Math.Ceiling,但它给出了与Math相同的内容.Round
i am tried "Math.Ceiling" but it gives out same as a "Math.Round"
他们不会给出相同的结果,请尝试:
They do NOT give 'the same results', try:
Dim a() As Double = {1.2, 95.55}
Dim ro(2) As Double
Dim ce(2) As Double
ro(0) = Math.Round(a(0))
ro(1) = Math.Round(a(1))
ce(0) = Math.Ceiling(a(0))
ce(1) = Math.Ceiling(a(1))
Console.WriteLine("ro(0)={0}, ro(1)={1}", ro(0), ro(1))
Console.WriteLine("ce(0)={0}, ce(1)={1}", ce(0), ce(1))
[/ update 2]
Dim ldblamount as double
ldblamount = val(100.01)
如果Int(ldblamount)<> ldblamount然后
ldblamount = Int(ldblamount)+ 1
结束如果
'结果
我的价值结果
100.00 100
100.01 101
100.99 101
Dim ldblamount as double
ldblamount = val("100.01")
If Int(ldblamount) <> ldblamount Then
ldblamount = Int(ldblamount) + 1
End If
'Result
I Value Result
100.00 100
100.01 101
100.99 101
您好,我是该站点的新成员试试这个-Int(-1.2)对我来说没问题
Hi, am a new member on the site try this -Int(-1.2) works ok for me
这篇关于如何获得圆值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!