1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

nicer print for cld

This commit is contained in:
Zeno Rogue 2020-05-01 17:27:13 +02:00
parent ee6b500822
commit ea8a3ea7d2

View File

@ -279,7 +279,21 @@ struct indenter_finish : indenter {
#endif
EX void print(hstream& hs, cld x) { print(hs, real(x)); if(kz(imag(x))) print(hs, "+", imag(x), "i"); }
EX void print(hstream& hs, cld x) {
int parts = 0;
if(kz(real(x))) {
print(hs, real(x));
parts++;
}
if(kz(imag(x))) {
if(parts && imag(x) > 0) print(hs, "+");
parts++;
print(hs, imag(x), "i");
}
if(!parts) print(hs, 0);
}
EX string fts_fixed(ld x, int prec IS(6)) {
std::stringstream ss;