If I have a number I can use printf (%,i,g,f,e,...) to format it in the way I want to display it onscreen. But how do to the reverse? Suppose the user give me a number, how can I get the format out of it? I use that number to generate another number, but I want to return it to the user in the same format as his number (e.i. the same precision).
This is more of an algorithm question than xCode/cocoa question, I know. Does anyone perhaps knows a good site with basic computer science algorithms, where such questions are more appropriate?
Thanks.
---
This is what I tried, but which doesn't work for some reason.
This is more of an algorithm question than xCode/cocoa question, I know. Does anyone perhaps knows a good site with basic computer science algorithms, where such questions are more appropriate?
Thanks.
---
This is what I tried, but which doesn't work for some reason.
Code:
float userInput = 3.1415;
float integral;
float frac = modff(interval,& integral);
int a=0;
while (frac != 0.0) {
frac = frac*10;
a++;
frac = modff(frac,&integral);
};