double.tostring()行为不一致
IM将字符串转换为double,然后将转换的值分开,如下所示。
double.TryParse(stringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out double convertedValue);
var splitValue = convertedValue.ToString(CultureInfo.InvariantCulture).Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
从Nunit TestCase和应用程序运行时,上述代码段的行为是不同的。
例如:
如果StringValue =“ 0.0000000000000000000000000000003402823499999999”“
从N-Nunit运行时:
convertedValue = 3.4028234999999987E-21
splitValue[0]= "3";
splitValue[1] = "4028235E-21"
从应用程序运行时,
convertedValue = 3.40282349999999E-21
splitValue[0]= "3";
splitValue[1] = "40282349999999E-21"
我想了解这种行为的原因吗?
Im converting a string to double and then splitting the converted value as shown below.
double.TryParse(stringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out double convertedValue);
var splitValue = convertedValue.ToString(CultureInfo.InvariantCulture).Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
The behavior of the above code snippet is different when run from Nunit testcase and from the application.
for example:
if stringValue="0.000000000000000000003402823499999999""
when run from n-nunit:
convertedValue = 3.4028234999999987E-21
splitValue[0]= "3";
splitValue[1] = "4028235E-21"
When run from the application
convertedValue = 3.40282349999999E-21
splitValue[0]= "3";
splitValue[1] = "40282349999999E-21"
I wanted to understand the reason for this behavior ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论