You are probably looking for something like std::format(L"{}, {}, {}", colorVal % 256, (colorVal / 256) % 256, colorVal / 65536)
how to using std::format for numerics?
asked 2021-11-08T03:39:40.813+00:00

DangDKhanh-2637
706
Reputation points
Hi,
I'm translating code from .NET.
Can I format wstring for multiple parameters at once?
I am trying to format rgb color base long color:
const wstring s = std::format(to_wstring(colorVal % 256), L"00") + L", " +
std::format(to_wstring((colorVal / 256) % 256), L"00") + L", " +
std::format(to_wstring(colorVal / 65536), L"00");
However the code seems to be quite slow, can you point me to a better approach?
Thank you!
Accepted answer
-
answered
2021-11-08T03:58:27.91+00:00 Igor Tandetnik 1,096 Reputation points