Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] subtracting ascii's hex value in a 64 bit hex value

Status
Not open for further replies.

Pradeep Channagiri

Newbie level 3
Joined
Mar 31, 2015
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
25
i have some ascii characters in a char variable.ex - char buf[100]="ab*(z&";
So each of the char in that char array will have some hex value.ex- *'s hex value is '2a'.
And i have a long long int variable in which there is a 64 bit hex value.
ex- long long int k=0x0000888888888888;
Now i want to subtract the char buff's hex value in k.How to accomplish it.please help.
That is 0x0000888888888888
- 0x000061622a287a26

= 0x000027265e600e62 (final result in a buffer or a long variable is okay)

Later i want to reverse the result as 26e006e56272.It should be stored in a variable such that i should be able to access each byte from it(ex- '72'(last 2 hex digits)).
Am stuck in this part in a very big project from Harman technologies.Please do help.
Thank You in advance.
 

Some points missing in your specification. How should substraction be performed for length(buf) > 8? Also the unused buf space beyond terminating 0 has to be zero filled.

You can convert the buffer content (first 8 characters) to a long log variable like this

Code:
long long ll = 0;
strncpy((char*)&ll,buf,8);
 
Thank you so much ...It helped a lot .. :)

It was very helpfull,there one more query,now i have subtracted result in a long long variable,
long long int k=0x61626364.
now i want to reverse the data in the variable k.that is ex- i want 'k' to be= 46362616.
thank you in advance.... :)
am very greatful for you :)
 

Do want to reverse the number nibble (4-Bit entity)-wise? Or reverse the byte order? The example is somehow unclear because you showed a 32 Bit value for the long long (64-Bit) variable.
 

    V

    Points: 2
    Helpful Answer Positive Rating
i want to reverse the number by nibble wise.for example -i have
unsigned long long int k=0x0000888804eaad0e; - I want to reverse it and need result in another long long int variable as-

result=q=0x0000e0daae408888 , if the result is like below is also okay

i,e- r=0xe0daae4088880000 , I need any of the above two results in unsigned long long it,How can i accomplish it,Thank you....Your response means a lot to me....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top