How to set up C++ Number Formatting to a certain precision?
-
22-09-2019 - |
문제
I understand that you can use iomanip to set a precision flags for floats (e.g. have 2.0000 as opposed to 2.00).
Is there a way possible to do this, for integers?
I would like a hex number to display as 000e8a00 rather than just e8a00 or 00000000 rather than 0.
Is this possible in C++, using the standard libraries?
해결책
기본 키 선언의 순서입니다.항상 place_id
를 검색하는 경우 먼저 post_id
를 선언하십시오.
PRIMARY KEY (place_id, post_id)
. 다른 팁
You can also do this with boost::format, which I find often saves typing:
std::cout << boost::format("%08x\n") % 0xe8a00;
It also allows for some nice code reuse, if you have multiple places you need to do the same formatting:
boost::format hex08("%08x"); std::cout << hex08 % 0xe8aa << std::endl;
제휴하지 않습니다 StackOverflow