Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Get lower 32 bits from uint64

Haojian Wu edited this page Apr 12, 2018 · 1 revision

Just assign to the destination integer -- uint32_t lower = static_cast<uint32_t>(my_uint_64).

This is safe, from The C++ Programming Language 10.5.2.1

If the destination type is unsigned, the resulting value is simply as many bits from the source as will fit in the destination (high-order bits are thrown away if necessary);

If the desination type is signed, the value is unchanged if it can be represented in the destination type; otherwise, the value is implementation-defined

Tech-Notes

LLVM/Clang

C/C++

Linux

Vim

Tools

Others

Chromium-Dev tips

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /