Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: sum of 64 b...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 20 Topic 26197 of 26822
Post > Topic >>

Re: sum of 64 bits using 32 bits cpu

by Hallvard B Furuseth <h.b.furuseth@[EMAIL PROTECTED] > May 13, 2008 at 07:45 PM

sarahh writes:
> 1.I know that the limit of unsigned integer is ~64000

....on a host where unsigned int is 32-bit like on your question, yes....

> what happend in case of overflow it start again from 0.?

Yes.  With 32-bit unsigned int, 0xffffffffU (all bits = 1) + 1U == 0.
Unsigned arithmetic is defined as modulo-(max value + 1) arithmetic.

(Strictly speaking this is not what is called overflow in the C language
- precisely because it is well-defined.  "overflow" is what happens to
signed integers, where the result is not defined.)

> 2.could someone add solution for the question?

The point of homework is to learn by doing.  But if you need a hint:
Think of how you do addition of two-digit numbers by hand, and think
of low and high as the two digits of a number.  (In base 0x100000000
instead of base 10, but what the hey...)  You need to check somehow
whether there was carry from adding the "low" digits.

-- 
Hallvard
 




 20 Posts in Topic:
sum of 64 bits using 32 bits cpu
sarahh <cohen200@[EMAI  2008-05-13 10:17:25 
Re: sum of 64 bits using 32 bits cpu
Spiros Bousbouras <spi  2008-05-13 10:40:08 
Re: sum of 64 bits using 32 bits cpu
Hallvard B Furuseth <h  2008-05-13 19:45:22 
Re: sum of 64 bits using 32 bits cpu
sarahh <cohen200@[EMAI  2008-05-13 11:17:36 
Re: sum of 64 bits using 32 bits cpu
sarahh <cohen200@[EMAI  2008-05-13 11:28:04 
Re: sum of 64 bits using 32 bits cpu
roberson@[EMAIL PROTECTED  2008-05-13 18:47:57 
Re: sum of 64 bits using 32 bits cpu
Hallvard B Furuseth <h  2008-05-13 22:27:00 
Re: sum of 64 bits using 32 bits cpu
Spiros Bousbouras <spi  2008-05-13 11:46:39 
Re: sum of 64 bits using 32 bits cpu
Szabolcs Borsanyi <bor  2008-05-14 02:14:55 
Re: sum of 64 bits using 32 bits cpu
sarahh <cohen200@[EMAI  2008-05-14 03:47:02 
Re: sum of 64 bits using 32 bits cpu
Eligiusz Narutowicz<el  2008-05-14 13:07:00 
Re: sum of 64 bits using 32 bits cpu
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-14 05:22:28 
Re: sum of 64 bits using 32 bits cpu
=?ISO-8859-1?Q?Tom=E1s_=D  2008-05-14 05:29:16 
Re: sum of 64 bits using 32 bits cpu
Hallvard B Furuseth <h  2008-05-14 14:37:58 
Re: sum of 64 bits using 32 bits cpu
"rio" <a@[EM  2008-05-14 18:57:35 
Re: sum of 64 bits using 32 bits cpu
Bart <bc@[EMAIL PROTEC  2008-05-14 05:35:08 
Re: sum of 64 bits using 32 bits cpu
richard@[EMAIL PROTECTED]  2008-05-14 14:56:41 
Re: sum of 64 bits using 32 bits cpu
Eligiusz Narutowicz<el  2008-05-14 14:51:32 
Re: sum of 64 bits using 32 bits cpu
Szabolcs Borsanyi <bor  2008-05-14 06:10:24 
Re: sum of 64 bits using 32 bits cpu
Spiros Bousbouras <spi  2008-05-14 07:52:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 1:21:08 CDT 2008.