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 18 of 20 Topic 26179 of 27679
Post > Topic >>

Re: sum of 64 bits using 32 bits cpu

by Eligiusz Narutowicz<eligiuszdotnaru@[EMAIL PROTECTED] > May 14, 2008 at 02:51 PM

Tomás Ó hÉilidhe <toe@[EMAIL PROTECTED]
> writes:

> On May 14, 12:07 pm, Eligiusz Narutowicz<eligiuszdotn...@[EMAIL PROTECTED]
>
> wrote:
>
>> I often wonder about this nonsensical part of the standard.
>
>
> Are you referring to the overflow of signed integers having undefined
> behaviour? If so:
>
> The reason for this, I think, is that there are many processors that
> have a "STATUS" register which uses bits to store such info as:
>     * The result of the last arithmetic operation was 0.
>     * The last arithmetic operation overflowed.
>
> If you had:
>
>     int i = 7;
>
>     i -= 34;
>
>     /* Now the STATUS register says there was overflow */

This was probably not the xample you intended as there is no overflow.

>
>     if (i) DoSomething();
>
> When the compiler sees "if (i)", it will simply check the STATUS
> register to see if the last operation resulted in zero. If an unsigned
> type is involved, then it's possible to have overflow and zero at the
> same time. With signed however, it doesn't bother checking for
> overflow, it just checks for zero. This is unreliable for some reason.
> Something along those lines in anyway.
>
> Somebody posted a nice anecdote about how people were complaining to a
> compiler manufacturer about getting dodgy behaviour out of "if (i)"
> after an overflow occurred, but the compiler writer was in strict
> abidance of the C89 Standard.
 




 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 Sat Oct 11 21:16:01 CDT 2008.