Qt 10 converted to hex

Source: Internet
Author: User
 
decimal int converted to hex char[]
void Dec2hex (int x,char s[])
{
 int i,j,c;

 for (I=-1;x>0;i)
 {
  s[++i]=x%16;
  x/=16;
 }
 for (j=i;j>=0;j--)
 {
     if (s[j]<10) s[j]+=48;
     else s[j]+=55;
     s[i+1]= ' + ';
 }
 for (j=0;j<i;j++,i--)
 {c=s[j];s[j]=s[i];s[i]=c;}

}
Decimal string qstring converted to hexadecimal char, extracted 8 bits high, 8 bits lower
 
Char extractlow (QString str)
{
    bool OK;
    int Dec=str.toint (&ok,10)%256;
    QString hex= qstring::number (Dec, +). ToUpper ();
    Char Low=hex.toint (0,16);
    return low;
}
Char Extracthigh (QString str)
{
    bool OK;
    int Dec=str.toint (&ok,10)/256;
    QString hex= qstring::number (Dec, +). ToUpper ();
    Char High=hex.toint (0,16);
    return high;
}


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.