There are 45 messages in this thread.
You are currently looking at messages 30 to 40.
Eric Smith wrote: > CBFalconer <c...@yahoo.com> writes: > >>>>> to get all 1s, better is ~0 >>>> How is that better? >>> should work on 1s-complement machines. > >> So does "unsigned int u = -1;". > > On a 1's complement machine, that will result in the variable ul > having al bits set other than the least signficant bit, since that > is the one's complement representation of -1. Which is what was wanted. -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section. -- Posted via a free Usenet account from http://www.teranews.com
On 19 Jan., 17:41, Albert van der Horst <alb...@spenarnc.xs4all.nl> wrote: > In article <47914AAB.E10DF...@yahoo.com>, > > >You can enter the value in hex, octal, or decimal. For example: > > > unsigned int x; > > .... > > x = 0xffff; > >/* or */ x = 0177777; > >/* or */ x = 65535U; > >/* or */ x = 0170000 + 0xf00 + 255U; > > And the most convenient of all > x = -1; > > (For those not in the know, the definition of unsigned > explicitly makes this works. There may be an additional > advantage that it ports over to 64 bits more easily.) > > And of course: > > x = ~0; I would rather use ~0u. ~0 smells of undefined behaviour although most compilers will do it right. > > > > -- > Albert van der Horst, UTRECHT,THE NETHERLANDS > Economic growth -- like all pyramid schemes -- ultimately falters. > albert@spe&ar&c.xs4all.nl &=nhttp://home.hccnet.nl/a.w.m.van.der.horst regards, Mark
msg <m...@_cybertheque.org_> writes: > I don't have my old manuals handy; was the Unisys 10000 series > 1's complement? I don't know about any 10000 series, but the 1100 series was.
Eric Smith wrote: > msg <m...@_cybertheque.org_> writes: > >>I don't have my old manuals handy; was the Unisys 10000 series >>1's complement? > > > I don't know about any 10000 series, but the 1100 series was. My apologies; I transposed NCR and Unisys in my mind. The NCR 10000 Series was a successor to early NCR architectures contemporary with the Univac 1107. Michael
I now submit to the public domain, free of charge...
enum {
b0000,
b0001,
b0010,
b0011,
b0100,
b0101,
b0110,
b0111,
b1000,
b1001,
b1010,
b1011,
b1100,
b1101,
b1110,
b1111,
};
lol
Most of the embedded people did something similar
#define b00000000 0
#define b00000001 1
. . .
before 0b....
was implemented as an extension in most compilers including ours.
w..
CodeDog wrote:
> I now submit to the public domain, free of charge...
>
> enum {
> b0000,
> b0001,
> b0010,
> b0011,
> b0100,
> b0101,
> b0110,
> b0111,
> b1000,
> b1001,
> b1010,
> b1011,
> b1100,
> b1101,
> b1110,
> b1111,
> };
>
> lol
Walter Banks wrote: > Most of the embedded people did something similar > > #define b00000000 0 > #define b00000001 1 > . . . > > before 0b.... > > was implemented as an extension in most compilers including ours. > I'd guess that "most of the embedded people" used hex or some sort of (1 << n) notation. But it's nice having 0b numbers available - is it common on other compilers yet? (gcc has it from 4.3 onwards, with avr-gcc supporting it from much earlier.)
David Brown wrote: > Walter Banks wrote: > > Most of the embedded people did something similar > > > > #define b00000000 0 > > #define b00000001 1 > > . . . > > > > before 0b.... > > > > was implemented as an extension in most compilers including ours. > > > > I'd guess that "most of the embedded people" used hex or some sort of (1 > << n) notation. But it's nice having 0b numbers available - is it > common on other compilers yet? (gcc has it from 4.3 onwards, with > avr-gcc supporting it from much earlier.) Many embedded compilers now to support 0b.... I don't have a list of who does support the binary syntax. I raised the issue at WG-14 one time and support was divided between hosted vs non-hosted experience. The hosted folks suggested 0x... was all that was needed. w..
In article <4...@bytecraft.com>, Walter Banks says... > > > David Brown wrote: > > > Walter Banks wrote: > > > Most of the embedded people did something similar > > > > > > #define b00000000 0 > > > #define b00000001 1 > > > . . . > > > > > > before 0b.... > > > > > > was implemented as an extension in most compilers including ours. > > > > > > > I'd guess that "most of the embedded people" used hex or some sort of (1 > > << n) notation. But it's nice having 0b numbers available - is it > > common on other compilers yet? (gcc has it from 4.3 onwards, with > > avr-gcc supporting it from much earlier.) > > Many embedded compilers now to support 0b.... I don't have a list of who > does support the binary syntax. I raised the issue at WG-14 one time and > support was divided between hosted vs non-hosted experience. The > hosted folks suggested 0x... was all that was needed. I tend to agree with them. I find reading hex (or x << y) a lot easier than counting bits in a binary number. Robert ** Posted from http://www.teranews.com **
Robert Adsett wrote: > In article <4...@bytecraft.com>, Walter Banks says... > >> >>David Brown wrote: >> >> >>>Walter Banks wrote: >>> >>>>Most of the embedded people did something similar >>>> >>>>#define b00000000 0 >>>>#define b00000001 1 >>>>. . . >>>> >>>>before 0b.... >>>> >>>>was implemented as an extension in most compilers including ours. >>>> >>> >>>I'd guess that "most of the embedded people" used hex or some sort of (1 >>><< n) notation. But it's nice having 0b numbers available - is it >>>common on other compilers yet? (gcc has it from 4.3 onwards, with >>>avr-gcc supporting it from much earlier.) >> >>Many embedded compilers now to support 0b.... I don't have a list of who >>does support the binary syntax. I raised the issue at WG-14 one time and >>support was divided between hosted vs non-hosted experience. The >>hosted folks suggested 0x... was all that was needed. > > > I tend to agree with them. I find reading hex (or x << y) a lot easier > than counting bits in a binary number. Reading binary numbers is easier when the language lets you separate the binary digits into logical groups, for example with underscores as in the Ada form: 2#10_10110_001000_11111_1_0000000010000# which is the 32-bit encoding of the SPARC instruction "addx r31,16,r22", grouped according to the logical fields of the encoding. The "_" has no numerical meaning, so the above is the same as: 2#10101100010001111110000000010000# Perhaps the C compilers that support the 0b... notation should allow some form of grouping like this. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .