zoukankan
html css js c++ java
四舍五入
public
static
double
Round(
double
d,
int
i)
{
if
(d
>=
0
)
{
d
+=
5
*
Math.Pow(
10
,
-
(i
+
1
));
}
else
{
d
+=
-
5
*
Math.Pow(
10
,
-
(i
+
1
));
}
string
str
=
d.ToString();
string
[] strs
=
str.Split(
'
.
'
);
int
idot
=
str.IndexOf(
'
.
'
);
string
prestr
=
strs[
0
];
string
poststr
=
strs[
1
];
if
(poststr.Length
>
i)
{
poststr
=
str.Substring(idot
+
1
, i);
}
string
strd
=
prestr
+
"
.
"
+
poststr;
d
=
Double.Parse(strd);
return
d;
}
查看全文
相关阅读:
iOS NSString中的搜索方法rangeOfString
iOS 远程推送通知
iOS PushMeBaby日志提示SSLwrite():-36 94
iOS [[NSBundle mainBundle] pathForResource:@"" ofType:@""]无法获取到文件
iOS 申请测试用的远程推送证书
数据结构与算法学习笔记(五)
iOS 上传新版本到AppStore时报错ITMS-90034
数据结构与算法学习笔记(四)
数据结构与算法学习笔记(三)
iOS开发日记49-详解定位CLLocation
原文地址:https://www.cnblogs.com/jetz/p/449106.html
最新文章
不规则button,不规则view的创建
实现不规则形状的按钮
如何创建一个渐变背景色的按钮
NSString 使用
二维码相关
iOS 网络状态
SDWebImage 的安装(转自官方文档)
UILabel 常用属性(转)
ios 问题集
iOS项目实现SVN代码管理方法②
热门文章
iOS项目实现SVN代码管理方法①
iOS面试题集锦
iOS开发之CocoaPods的安装与使用
iOS项目开发中的知识点与问题收集整理②
iOS阶段学习第35天笔记(Touch手势介绍)
iOS阶段学习第34天笔记(UI小组件 UISegment-UISlider-UIStepper-UIProgressView-UITextView介绍)
iOS阶段学习第33天笔记(自定义标签栏(UITabBar)介绍)
iOS阶段学习第32天笔记(页面传值方法介绍)
MesaSQLite数据库的简单使用方法
iOS App之间跳转
Copyright © 2011-2022 走看看