Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- printf("%1.3f", 359.01335);
- printf("%1.3f", 359.00999);
- 359.013
- 359.010
- 359.013
- 359.01
- printf("%.6g", 359.013); // 359.013
- printf("%.6g", 359.01); // 359.01
- printf("%.6g", 3.01357); // 3.01357
- char str[50];
- sprintf (str,"%.20g",num); // Make the number.
- morphNumericString (str, 3);
- : :
- void morphNumericString (char *s, int n) {
- char *p;
- int count;
- p = strchr (s,'.'); // Find decimal point, if any.
- if (p != NULL) {
- count = 3; // Adjust for more or less decimals.
- while (count >= 0) { // Maximum decimals allowed.
- count--;
- if (*p != '