我的问题与这个问题类似:。 • 如何获得国家测量局或国家测量局的无计划代表? 我需要具备一些精确代表国家独立网络的示意图格式,但这一数目却被转回其他地方,我可以避免。 问题一是,当数字重新转化为扼杀时,在某些情形下,扼杀在科学上。
NSDecimalNumber *dn = [NSDecimalNumber decimalNumberWithString:@"0.0001"];
NSString *s = [dn stringValue]; // s will be @"1E-4"
I am working in a circa 2005 version of GNUstep (possibly v1.11.1 for GNUstep Base), rather than on mac or iPhone, which may account for some of the differences in behavior vs the other question I referenced. I have looked over the base library API and the documentation in my own GNUstep install, but I can t seem to find anything to help.
<EDIT 2/7/12:
The question has changed slightly, but the goal is still the same. Originally, I didn t think I was able to control the string output piece, but I can pass the value back as a string. At this point I am attempting to use a formatting string, but I still want to prevent the scientific notation from appearing.
[NSString stringWithFormat:@"%1.14g", [val doubleValue]]
我选择使用<代码>%g,因为我们要获得一定数目的重要数字。 如果我使用<条码>%f,我可以将额外零打上下,但数字并不总是干净的。 例如,800 000.79 似乎为800 000.78999600。
www.un.org/Depts/DGACM/index_spanish.htm 是否有办法获得一定数量的高位数(或小数位)的干净格式数字,在位数之前显示科学位数?
我也愿意接受C项建议。