how to make a long long

LLeweLLyn Reese llewelly@lifesupport.shutdown.com
Mon Feb 24 05:51:00 GMT 2003


Sebastian Huber <sebastian-huber@web.de> writes:

> On Saturday 22 February 2003 22:34, you wrote:
> > Sebastian Huber <sebastian-huber@web.de> writes:
> > > Adrian Sandor <aditsu@yahoo.com> schrieb am 22.02.03 16:44:50:
> > > > > what is wrong with
> > > > >
> > > > > unsigned long long i = ((0x0ULL | uint32high) << 32)
> > > > >
> > > > > | uint32low;
> > > > >
> > > > > ?
> > > >
> > > > this approach uses an OR between an unsigned long long
> >
> > OR often has the lowest latency and highest paralellism a cpu can
> >     offer. It is much simpler than, for example, add or increment.
> >
> > > > and an unsigned int, a SHIFT-LEFT on an unsigned long
> > > > long and another OR between 2 an unsigned long long
> > > > and an unsigned int;
> > > > I think these are too heavy calculations just for
> > > > putting 2 unsigned ints next to each other
> >
> > I doubt it. There have been a few microcontrollers for whom SHIFT-LEFT
> >     was/is expensive, but they are a minority.
> >
> > > C is not an assembly language. It's up to the compiler to generate
> > > optimized code.
> >
> > If you actually need optimized code, the programmer has to write it,
> >     regardless of the language. The compiler merely allows one to
> >     concentrate on the code that needs optimization most.
> 
> You should interpret my statement in view of this special problem.

I'm sorry, I've no idea what you mean by that. Which statement? What
    special problem?

> If you want 
> to play with bits in plain C your tools are limited.

This is true, but they are often adequate. (and frankly better than
    most non-assembler languages.) If you need assembler, use it, but
    know how to seperate such platform specific code from non-platform
    specific code.



More information about the Gcc-help mailing list