简体   繁体   中英

unexpected behaviour from conversion from long long to int

I'm working on VS2019, in windows 10 64bit. I was doing some try and I tried the following code

int main() {
    unsigned long long ull = 70000;
    unsigned int ui = ull;
    std::cout << ui;
}

I would expect to get an output different from 70000, because 70000 is bigger then then the biggest number that an int variable can store. so why do I get 70000 as output? how is that possible?

A 32 bit unsigned int can store values from 0 to 4,294,967,295.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM