how to create 64 bit int, unsigned long long variable with c++

Submitted by rex on Mon, 03/14/2011 - 23:39


#include <stdio.h>
#include <inttypes.h>

int main(){

uint64_t x = -10033333000;
int64_t y = 113333334445533;

// print x as unsigned variable PRIu64
printf("value of x is: %" PRIu64 ,x);
printf("\n");
// print x as integer variable PRIi64
printf("value of y is: %" PRIi64,y);
printf("\n");

// this is the same like y
unsigned long long z = -212121212121;
printf("value of z is: %llu",z,"\n");
printf("\n");

return 0;
}

gcc int64bit.c -o int64bit
int64bit.c: In function ‘main’:
int64bit.c:8: warning: integer constant is too large for ‘long’ type
int64bit.c:9: warning: integer constant is too large for ‘long’ type
int64bit.c:18: warning: integer constant is too large for ‘long’ type
rex@ubuntu:~/cpp$ ./int64bit
value of x is: 18446744063676218616
value of y is: 113333334445533
value of z is: 18446743861588339495


Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.