02.04.2018, 10:09
YIL the internal buffer for formatting floating point numbers is 64 characters:
Should give numbers with 100 decimal places (mostly all zeros), but doesn't:
Edit:
I'll also expand on what Freaksken said (I didn't learn this today, I wrote the original code for it). You can combine variable width and precision, plus zero prefixes:
Even better, this can totally replace "substring" code:
PHP код:
new str[256];
format(str, sizeof (str), "%7.0100f", 4.4);
print(str);
printf("%7.0100f", 4.4);
Код:
4.40000009536743164062500000000000000000000000000000000000 4.40000009536743164062500000000000000000000000000000000000
I'll also expand on what Freaksken said (I didn't learn this today, I wrote the original code for it). You can combine variable width and precision, plus zero prefixes:
PHP код:
printf("%0*.*f", 3, 5, 4.4); // Gives "004.40000"
PHP код:
new str[] = "How are you?"
printf("%.3s", str[4]); // Gives "are"