Thread: How to display a 64-bit integer?

  1. #1
    Unregistered
    Guest

    Question How to display a 64-bit integer?

    I'm trying to figure out how to write a function to print a 64-bit integer value.

    Newer compilers have a built in 64-bit type, like in gcc its 'long long' and in Windows compilers its __int64. Anyway, I tried splitting it into 2 32-bit ints, but I can't figure out where to go from there. Any ideas?

  2. #2
    Unregistered
    Guest

    in decimal form

    by display it i mean print it in decimal form

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    7
    in visual c++ for __int64 usesomething like

    __int64 a=10;
    char buff[256];

    sprintf(buff, "%I64u", a);
    ............

    and there you go, should you want to use cout, then overload the << operator for ostream with support for __int64, very simple.

    sincrely

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pthreads for 64 bit m/c
    By vin_pll in forum C Programming
    Replies: 2
    Last Post: 02-22-2009, 10:25 PM
  2. Writing 64 bit value in hex to a string
    By rahulgbe in forum C Programming
    Replies: 2
    Last Post: 03-18-2006, 01:15 PM
  3. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 08:02 PM
  4. polymorphism - 64 bit - va_arg - advanced
    By anonytmouse in forum C Programming
    Replies: 2
    Last Post: 12-03-2003, 09:27 AM