Creazione stringa formattata.
Sintassi |
string string::format(int64 value, const string &in options="", uint width=0) string string::format(uint64 value, const string &in options="", uint width=0) string string::format(double value, const string &in options="g", uint width=0, uint precision=16) |
||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
Valore da formattare |
||||||||||||||||||||||
options |
Opzioni di formattazione (opzionali). Le opzioni disponibili sono:
Nota (#1): opzione applicabile solo con valore tipo double. |
||||||||||||||||||||||
width |
Numero di cifre per il valore (opzionale; 0=automatico) |
||||||||||||||||||||||
Risultato |
Rende la stringa formattata |
Esempio di utilizzo:
string value1 = string::format(1000); /* value1 contiene "1000" */ string value2 = string::format(6.28, "f", 0, 2); /* value2 contiene "3184.71337579617830" */ string value3 = string::format(6.28, "e", 0, 2); /* value3 contiene "3.18471337579618e+03" */ string value4 = string::format(10000.0/3.14); /*! value4 contiene "3184.7133757962" */ string value5 = string::format(1000, "0h"); /* value5 contiene "3e8" */ string value6 = string::format(1000, "0h", 8); /* value6 contiene "000003e8" */ |