Y
yong
I rewrite my code but the uint64_t seems can't work well.
The code is here:
========================
#include <stdio.h>
#include <stdint.h>
#include "compress.h"
int main()
{
struct code6 mycode6;
struct code5 mycode5;
mycode6.item1=1;
mycode6.item2=2;
mycode6.item3=3;
mycode6.item4=4;
mycode6.item5=5;
mycode6.item6=6;
mycode5=codecompress(mycode6);
printf("mycode5.item1 is: %d\n",mycode5.item1);
printf("mycode5.item2 is: %d\n",mycode5.item2);
printf("mycode5.item3 is: %d\n",mycode5.item3);
printf("mycode5.item4 is: %d\n",mycode5.item4);
printf("mycode5.item5 is: %d\n",mycode5.item5);
return 0;
}
========================
and the compress.h is here:
========================
#include <stdint.h>
struct code6
{
unsigned long item1;
unsigned long item2;
unsigned long item3;
unsigned long item4;
unsigned long item5;
unsigned long item6;
};
struct code5
{
unsigned long item1;
unsigned long item2;
unsigned long item3;
unsigned long item4;
unsigned long item5;
};
struct code5 codecompress(struct code6 origcode)
{
struct code5 ret;
uint64_t math64;
math64=origcode.item1*(256^5)+origcode.item2*(256^4)+origcode.item3*(256^3)+origcode.item4*(256^2)+origcode.item5*256+origcode.item6;
printf("math64 is: %X\n",math64);
ret.item5=(math64)%(uint64_t)900;
math64/=900;
ret.item4=(math64)%900;
math64/=900;
ret.item3=(math64)%900;
math64/=900;
ret.item2=(math64)%900;
math64/=900;
ret.item1=(math64)%900;
return ret;
}
========================
After the code runs it displays that
------------------------
math64 is: F24
mycode5.item1 is: 0
mycode5.item2 is: 0
mycode5.item3 is: 0
mycode5.item4 is: 4
mycode5.item5 is: 276
The code is here:
========================
#include <stdio.h>
#include <stdint.h>
#include "compress.h"
int main()
{
struct code6 mycode6;
struct code5 mycode5;
mycode6.item1=1;
mycode6.item2=2;
mycode6.item3=3;
mycode6.item4=4;
mycode6.item5=5;
mycode6.item6=6;
mycode5=codecompress(mycode6);
printf("mycode5.item1 is: %d\n",mycode5.item1);
printf("mycode5.item2 is: %d\n",mycode5.item2);
printf("mycode5.item3 is: %d\n",mycode5.item3);
printf("mycode5.item4 is: %d\n",mycode5.item4);
printf("mycode5.item5 is: %d\n",mycode5.item5);
return 0;
}
========================
and the compress.h is here:
========================
#include <stdint.h>
struct code6
{
unsigned long item1;
unsigned long item2;
unsigned long item3;
unsigned long item4;
unsigned long item5;
unsigned long item6;
};
struct code5
{
unsigned long item1;
unsigned long item2;
unsigned long item3;
unsigned long item4;
unsigned long item5;
};
struct code5 codecompress(struct code6 origcode)
{
struct code5 ret;
uint64_t math64;
math64=origcode.item1*(256^5)+origcode.item2*(256^4)+origcode.item3*(256^3)+origcode.item4*(256^2)+origcode.item5*256+origcode.item6;
printf("math64 is: %X\n",math64);
ret.item5=(math64)%(uint64_t)900;
math64/=900;
ret.item4=(math64)%900;
math64/=900;
ret.item3=(math64)%900;
math64/=900;
ret.item2=(math64)%900;
math64/=900;
ret.item1=(math64)%900;
return ret;
}
========================
After the code runs it displays that
------------------------
math64 is: F24
mycode5.item1 is: 0
mycode5.item2 is: 0
mycode5.item3 is: 0
mycode5.item4 is: 4
mycode5.item5 is: 276