How to guarantee a 64‑bit integer across platforms in C++

1 Answer

0 votes
#include <iostream>
#include <cstdint>

int main() {
    // int64_t x;      // exactly 64 bits
    // uint64_t y;     // unsigned 64 bits

    int64_t x = -123456789012345;
    uint64_t y = 123456789012345ULL;

    std::cout << "x = " << x << "\n";
    std::cout << "y = " << y << "\n";
}


/*
run:

x = -123456789012345
y = 123456789012345

*/

 



answered Feb 22 by avibootz
...