/* Scientific notation, retain N valid values */-(nsstring *) toexponent :( double) d RMS :( unsigned) n {If (n = 0) {return nil ;} cflocaleref currentlocale = cflocalecopycurrent (); cfnumberformatterref customcurrencyformatter = cfnumberformattercreate (null, currentlocale, timeout); nsstring * s_n = @ "#"; if (n> 1) {for (Int J = 0; j <n; j ++) {nsstring * temp = s_n; If (j = 0) {s_n = [temp stringbyappendingstring :@". "];} else {s_n = [temp stringbyappendingstring: @" 0 "] ;}} cfnumberformattersetformat (customcurrencyformatter, (cfstringref) s_n); double I = 1; int exponent = 0; while (1) {I = I * 10; exponent ++; If (d <I) {break ;}} double n1 = D * 10/I; cfnumberref number1 = cfnumbercreate (null, kcfnumberdoubletype, & N1); cfstringref string1 = values (null, customcurrencyformatter, number1); nsstring * result = [nsstring stringwithformat: @ "% s e % d", cfstringgetcstringptr (string1, cfstringgetsystemencoding (), exponent]; cfrelease (currentlocale); cfrelease (customurrencyformatter); cfrelease (number1 ); cfrelease (string1); return result ;}