Restore std::dec after std::hex

Code is leaking a std::hex, and causes subsequent
sync_cout output to be in hexadecimal.

Spotted by Lucas

No functional change.
Merge remote-tracking branch 'upstream/master' into accurate_pv
Fix undefined behavior