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="Walter Roberson, post: 2453144"] Unfortunately you did not quote any of the original task. In C, the ^ operator is "Exclusive OR". In your description of the original task, I would be surprised if your use of ^ did not indicate exponentiation there. In C, 256 to the power of 0 is 1 of 1 is 1<<8 of 2 is 1<<16 of 3 is 1<<24 of 4 is 1<<32 of 5 is 1<<40 On most systems, 1<<32 is bigger than an unsigned long will hold. C89 does not promise that anything from 1<<32 upwards is available. C99 does provide unsigned long long for that purpose, but you must be careful to avoid accidently working in narrower types in an intermediate stage. You do not actually need to use the multiplications or additions in your calculation of math64. Presuming C99, your code could instead be math64 = (unsigned long long) origcode.item1 << 40 | (unsigned long long) origcode.item2 << 32 | (unsigned long long) origcode.item3 << 24 | (unsigned long long) origcode.item4 << 16 | (unsigned long long) origcode.item5 << 8 | (unsigned long long) origcode.item6; [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Dealing with a large integer
Top