How to Print an __int64 Number in VC++

You can use the printf() function as in the following example:

 #include using namespace std;int main(){  __int64 i64 = 4294967296;  printf("%I64d
", i64); //in decimal  printf("%I64x
", i64); //in hexa  return 0;}

You can also use the function Int64ToString(). The next example transforms an __int64 into a string in a specified radix:

 #include #include #include string Int64ToString(__int64 const& ri64, int iRadix=10){  bool bNeg = (ri64 < 0);  __int64 i64 = ri64;  string ostrRes;  bool bSpecial = false;  if(true == bNeg)  {    i64 = -i64;    if(i64 < 0)      //Special case number -9223372036854775808 or _0x8000000000000000      bSpecial = true;    ostrRes.append(1, '-');  }  int iR;  do  {    iR = i64 % iRadix;    if(true == bSpecial)      iR = -iR;    if(iR < 10)      ostrRes.append(1, '0' + iR);    else      ostrRes.append(1, 'A' + iR - 10);    i64 /= iRadix;  }  while(i64 != 0);  //Reverse the string  string::iterator it = ostrRes.begin();  if(bNeg)    it++;  reverse(it, ostrRes.end());  return ostrRes;}int main(){  __int64 i64 = 4294967296;  cout << Int64ToString(i64) << endl; //in decimal  cout << Int64ToString(i64, 16) << endl; //in hexa  return 0;}
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may