+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Advanced Member level 1
    Points: 3,241, Level: 13

    Join Date
    Feb 2012
    Location
    Jeonju, South Korea
    Posts
    468
    Helped
    27 / 27
    Points
    3,241
    Level
    13

    problem in type 64 bit (long long and __int64)

    hello all


    I have a problem while dealing with 64-bit variable...The code shows it as 32 bit instead...What is wrong with it...

    Note that I have tried long long as well as __int64

    please see the code snippet[
    Code:
    #include<iostream>
    #include<fstream>
    #include <stdio.h>
    #include <Windows.h>
    #include <string.h>
    
    using namespace std;
    
    int main (void){
    signed short int *sh_pbuff;
    signed long long *ln_pbuff;
    __int64 long_temp = 0xfffffffffffffff; //previously used long long but got the same result as now
    
    printf("size of long is %I64d\n\n", sizeof(long_temp));
    printf("value of initialzition for long_temp is %x\n\n", long_temp);
    ..
    ..
    Click image for larger version. 

Name:	longerror.JPG 
Views:	4 
Size:	20.0 KB 
ID:	96808
    When the going gets weird, the weird turn pro.
    H.S. Thompson

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 260,224, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,442
    Helped
    13826 / 13826
    Points
    260,224
    Level
    100

    Re: problem in type 64 bit (long long and __int64)

    Wrong print format specifier? It's an implementation dependent thing, did you review the compiler manual?

    With gcc, %llx would be right for long long.



    •   AltAdvertisement

        
       

  3. #3
    Full Member level 4
    Points: 1,333, Level: 8
    embRTS's Avatar
    Join Date
    Sep 2013
    Location
    Bangalore
    Posts
    216
    Helped
    36 / 36
    Points
    1,333
    Level
    8

    Re: problem in type 64 bit (long long and __int64)

    You can use a header file
    #include<stdint.h>

    typedef uint64_t Variable NAME

    OR Simply INCLUDE a 'L' after the variable value name it itself indicates that it's 64 bit VBariable

    For example - unsigned long long rts = 50L;

    Here rts is a variable for 64 bit



--[[ ]]--