gpt4 book ai didi

c# - 转换为字符串时精度下降到 3 位大数字

转载 作者:行者123 更新时间:2023-12-04 14:55:35 24 4
gpt4 key购买 nike

我有以下类型的 double

var a_number = 105229626666.6667;

当我存储它或将其转换为字符串时,数字会自动截断为小数点后 3 位,而不是“105229626666.667”。

有没有办法规避这个问题?

Screenshot

最佳答案

试试这个:

number.ToString("R");

R 代表“往返”:

This format is supported only for the Single and Double types. The round-trip specifier guarantees that a numeric value converted to a string will be parsed back into the same numeric value.

参见 standard numeric format了解更多信息

关于c# - 转换为字符串时精度下降到 3 位大数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68096851/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com