Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Dealing with a large integer
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="yong, post: 2453165"] I rewrite my code and it seems run correctly now. main.c =================== #include <stdio.h> #include <stdint.h> #include <math.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; } =================== compress.h =================== #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*((uint64_t)pow(256,5))+origcode.item2*((uint64_t)pow(256,4))+origcode.item3*((uint64_t)pow(256,3))+origcode.item4*((uint64_t)pow(256,2))+origcode.item5*256+origcode.item6; 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; } =================== Thank you all. :] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Dealing with a large integer
Top