How to set a buffer size to 2 exabytes in C

1 Answer

0 votes
// An exabyte (binary) is:
              
// 1 EiB = 2 ^ 60 bytes = 1,152,921,504,606,846,976 bytes
                          
#include <stdio.h>
#include <locale.h>


#define EXABYTE     (1ULL << 60)              // 1 EiB (binary exabyte)
#define EXABYTE_DEC 1000000000000000000ULL    // 1 EB  (decimal exabyte)

int main(void) {
    // Set buffer size to 2 EiB
    unsigned long long buffer_size = 2 * EXABYTE;

    printf("Buffer size (2 EiB): %llu bytes\n", buffer_size);

     // Enable locale so %'llu prints commas (glibc only)
    setlocale(LC_NUMERIC, "");

    printf("Buffer size (2 EiB): %'llu bytes\n", buffer_size);

    return 0;
}


/*
run:

Buffer size (2 EiB): 2305843009213693952 bytes
Buffer size (2 EiB): 2,305,843,009,213,693,952 bytes

*/


 



answered 1 hour ago by avibootz
edited 1 hour ago by avibootz
...