double to string和string格式 [英] double to string and string format

查看:125
本文介绍了double to string和string格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

双号有tihs值:219.67377380133897



我试图使用格式字符串将其更改为字符串:



number.ToString(### 0.0 ###############)= 251.673773801339> (897)改为9

&

number.Tostring(F16)= 219.673773801339000> (897)改为9



有什么方法可以解决这个问题?

a double number has tihs value: 219.67377380133897

I''ve tried to change it to string using format strings:

number.ToString("###0.0###############") = 251.673773801339 > (897) changed by 9
&
number.Tostring("F16") = 219.673773801339000 > (897) changed by 9

Any way to solve this??

推荐答案

一个Double值已经最多15个十进制数字的精度,尽管内部最多保留17位数,双重结构 [ ^ ]。



如您所知,许多格式说明符只能访问15位数字。要查看全部17个,请使用往返说明符R或一般说明符G17。



Alan。
A Double value has up to 15 decimal digits of precision, although a maximum of 17 digits is maintained internally, Double structure[^].

As you have found out, many of the format specifiers will only access 15 digits. To see all 17 use the round trip specifier "R" or the general specifier "G17".

Alan.


这篇关于double to string和string格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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