troubleshooting Question

ASCII to Byte Conversion

Avatar of kakali
kakali asked on
C++
3 Comments1 Solution1041 ViewsLast Modified:
Hi,
I have a field whose decimal value is 36. I want to convert it to a 8 byte stream which will be represented as "00 00 00 00 00 00 00 24".

Now following is my code:

m_objDeviceDetail.strMerchantID.Format("%016d",_atoi64(m_objDeviceDetail.strMerchantID));

lngTemp=_atoi64(m_objDeviceDetail.strMerchantID);

if (lngTemp==0) return false;

ch=((lngTemp>>56) & 0xff);
strQBext.SetAt(0,ch);

ch=((lngTemp>>48) & 0xff);
strQBext.SetAt(1,ch);

ch=((lngTemp>>40) & 0xff);
strQBext.SetAt(2,ch);

ch=((lngTemp>>32) & 0xff);
strQBext.SetAt(3,ch);

ch=((lngTemp>>24) & 0xff);
strQBext.SetAt(4,ch);

ch=((lngTemp>>16) & 0xff);
strQBext.SetAt(5,ch);

ch=((lngTemp>>8) & 0xff);
strQBext.SetAt(6,ch);

ch=(lngTemp & 0xff);
strQBext.SetAt(7,ch);

But the out put I am getting is "00 00 00 24 00 00 00 24".

Can anyone help me to find out what should I do to get the desired result which is "00 00 00 00 00 00 00 24".

Thanks in advance
ASKER CERTIFIED SOLUTION
zhuba

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros