gpt4 book ai didi

iphone - cocoa - 将 double 转换为字符串

转载 作者:行者123 更新时间:2023-12-03 16:04:59 25 4
gpt4 key购买 nike

我有一个双数,我想将其转换为字符串。

例如,该数字类似于

24.043333332154465777...

但是如果我使用类似的东西将其转换为字符串

NSString *myString = [NSString stringWithFormat:@"%f", myDouble];

字符串只是

24.043333

如何获得与整个 double 相对应的完整字符串?我还需要什么其他方法来转换它?

最佳答案

另一种选择,因为您在对 mipadi 答案的评论中询问了其他方式:

使用 NSNumber *myDoubleNumber = [NSNumber numberWithDouble:myDouble]; 创建一个 NSNumber

然后调用[myDoubleNumber stringValue];

来自文档:

Returns the receiver’s value as a human-readable string, created by invoking descriptionWithLocale: where locale is nil.

关于iphone - cocoa - 将 double 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2471178/

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