Re: Fast sincos routine

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 03/08/04


Date: Mon, 08 Mar 2004 15:51:25 GMT

Clark Cox wrote:
> CBFalconer <cbfalconer@yahoo.com> wrote:
> > Larry Doolittle wrote:
> > > In article <404AB2CE.81FD61ED@yahoo.com>, CBFalconer wrote:
> > >
> > > > however
> > > >
> > > > if (a > 0) a = -a;
> > > >
> > > > will force it to the range INT_MIN .. 0. Thus this is the proper
> > > > operation when translating to text and extracting signs. The
> > > > result can now be fearlessly converted into an unsigned.
> > >
> > > And what then? That unsigned number cannot be twiddled
> > > to represent the absolute value, according to pete
> > > (pfiland@mindspring.com), who comes up with the example
> > > UINT_MAX == 65535
> > > INT_MIN == -65536
> > > CHAR_BIT == 16
> > > INT_MAX == 65535
> > > sizeof(unsigned) == 2
> > > sizeof(int) == 2
> > > and the generaliziation "unsigned isn't guaranteed to be
> > > able to represent the magnitude of INT_MIN."
> >
> > Yes it is. Of the legal integer representations, ones, twos
> > complement, and sign magnitude, there is always a sign bit
> > (specified). That bit is always available for reuse in an
> > unsigned, thus automatically doubling the range. The situation
> > above is not possible.
>
> After a quick glance, I see nothing in the standard that says
> that that extra bit actually *has* to be used. So I see no
> reason why an implementation can't have INT_MAX == UINT_MAX.

I believe sections 6.2.5 and 6.2.6.2 of N869 cover it. Things are
widely spread out, so it takes a Dan Pop to correlate everything.

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


Relevant Pages

  • Re: random_number
    ... 36 bits was "the standard" at one point in history. ... Some machines even used sign magnitude (twos complement in other jargons) for symmetric ranges. ...
    (comp.lang.fortran)
  • Re: sign magnitude, ones complement, twos complement
    ... >> two's complement ... >> What are the pitfalls of them? ... > I doubt if sign magnitude has ever been used in a popular US computer. ...
    (comp.lang.c)
  • Re: Intel Atom vs ARM
    ... that weren't powers of two, systems that weren't twos' complement, and ... I can assure you that handling what you describe isn't even ...
    (comp.arch)
  • Re: odd/even bitwise and
    ... >> It's also possible with Sign and Magnitude representation. ... > (The ones I know of are signed magnitude, one's complement, and two's ... You're not missing any representation methods allowed by the C ...
    (comp.lang.c)
  • Help with shifting
    ... I'm wondering why, and speculate from reading the HLA docu, that the ... reason I cannot obtain a positive number when using the twos ... complement in the following example is because of overflow: ...
    (comp.lang.asm.x86)