如何转换为加倍与2 precision - 串点后? [英] How to convert to double with 2 precision - string after dot?

查看:190
本文介绍了如何转换为加倍与2 precision - 串点后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这个字符串转换: 0.55000000000000004 来这双: 0.55 。 那怎么办?

I want to convert this string: 0.55000000000000004 to this double: 0.55. How to do that?

推荐答案

是一个字符串或双? 如果它是一个字符串:

Is a string or a double? If it is a string:

double d = double.Parse(s,CultureInfo.InvariantCulture);
string s=string.Format("{0:0.00}",d);

,如果它已经使用第二线的双重只是格式

if it is already a double just format using the second line.

这篇关于如何转换为加倍与2 precision - 串点后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆