How to define an exabyte constant 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
#define EXABYTE_DEC 1000000000000000000ULL       // 1 EB

int main(void) {
    unsigned long long size = EXABYTE;

    printf("1 EiB = %llu bytes\n", size);
     
     // Enable locale so %'llu prints commas (glibc only)
    setlocale(LC_NUMERIC, "");

    printf("1 EiB = %'llu bytes\n", size);

    return 0;
}



/*
run:

1 EiB = 1152921504606846976 bytes
1 EiB = 1,152,921,504,606,846,976 bytes

*/

 

 

 

 

 



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

Related questions

...