C#双圈 [英] C# Double Rounding
本文介绍了C#双圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public double round(double value){
BigDecimal b = new BigDecimal值);
b = b.setScale(2,BigDecimal.ROUND_UP);
return(b.doubleValue());
}
我写了这个转换代码,但我不能将其转换为c#.BigDecimal类型原因一些问题和我完全新的.Net.Definitely需要一些帮助。
编辑:好的,我得到它,抱歉的愚蠢的问题。
解决方案
难道你不能这样做到2个小数位数吗?
double foo = 3.143;
double fooRounded = Math.Round(foo,2);
I'm currently working on a program and im converting my java code into c# . but i'm having some trouble.
public double round(double value){
BigDecimal b = new BigDecimal(value);
b = b.setScale(2,BigDecimal.ROUND_UP);
return (b.doubleValue());
}
i wrote this converting code but i cant convert it to c#.BigDecimal type causes some problem and im totally new to .Net.Definitely need some help.
Edit : Ok buds i got it , sorry for the dumb question.
解决方案
Couldn't you just do this to round to 2 fractional digits?
double foo = 3.143;
double fooRounded = Math.Round(foo, 2);
这篇关于C#双圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文