Re: arm9e: how do I invert sign of a halfword?



Wilco Dijkstra wrote:
"CBFalconer" <cbfalconer@xxxxxxxxx> wrote:
Wilco Dijkstra wrote:

... snip ...

FYI The standard is actually incorrect here in making all negative
left shifts undefined. Positive leftshifts that overflow are
undefined too. However multiplies of positive and negative numbers
are defined if no overflow occurs, and only implementation defined
if they overflow...

There is no known error in the portion I quoted (and you snipped).
If you don't pay attention, you will sooner or later have to pay.

If you don't think it's an error, maybe you can explain why it is
correct?

Just consider the meaning and action on machines using ones
complement or sign-magnitude conventions. Also the fact that the
occurence of an overflow can cause implementation defined action.
That's why, for safe behaviour, you should restrict shifts to
operating on unsigned quantities.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


.



Relevant Pages

  • Re: arm9e: how do I invert sign of a halfword?
    ... FYI The standard is actually incorrect here in making all negative ... Positive leftshifts that overflow are ... If you don't pay attention, you will sooner or later have to pay. ...
    (comp.arch.embedded)
  • Re: arm9e: how do I invert sign of a halfword?
    ... Positive leftshifts that overflow are ... However multiplies of positive and negative numbers ... If you don't pay attention, you will sooner or later have to pay. ...
    (comp.arch.embedded)
  • Re: .net 2003 vs vc6 performance
    ... Turned off overflow checks ... Your VB.NET code is doing 64-bit multiplies. ... optimizations. ... Made a COM in VC++ which is executing following code: ...
    (microsoft.public.dotnet.framework.performance)
  • [PATCH 2/7] s390: overflow in sched_clock.
    ... method multiplies first and then shifts the value to make the result ... with 1000 will overflow shortly after 52 days. ... by the scheduler for time stamp deltas, ... two time stamps the scheduler will get confused. ...
    (Linux-Kernel)
  • Re: how to specify power of number
    ... unsigned long long r, bit, pow; ... The hardest part is checking for overflow - left as an exercise for ... b integer multiplies. ... exponents of 2 that occur in the binary expansion of b. ...
    (comp.lang.c)