How to Print an __int64 Number in VC++

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:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes