Prev: high dimensional index structures for arbitrary distance/similarity functions (text mining)
Next: Q: Parallel processing for multi-precision arithmetics
From: Richard Heathfield on 3 Jun 2010 06:50 bart.c wrote: > <snip> > It seems reasonable to be able to request 'a' to be exactly 16-bits on > any machine, whether that is natural for the architecture on not. I'm not entirely convinced that that /is/ a reasonable request. It is perfectly reasonable to ask for it to be *at least* 16 bits. How, precisely, would you implement your exactly-16-bit type on a machine whose natural word size is 64? Such a machine does exist, and C implementations for it have to jump through all kinds of crazy hoops to give programmers the 8-bit char they expect. I would not like to be the one to tell the compiler team "well done lads, but now there's this bloke on Usenet who wants 16-bit short ints..." -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ "Usenet is a strange place" - dmr 29 July 1999 Sig line vacant - apply within
From: Richard Heathfield on 3 Jun 2010 09:24 Dann Corbit wrote: > In article <2qmdnQNJioRrFZrRnZ2dnUVZ8nmdnZ2d(a)bt.com>, > rjh(a)see.sig.invalid says... >> bart.c wrote: >> <snip> >> >>> It seems reasonable to be able to request 'a' to be exactly 16-bits on >>> any machine, whether that is natural for the architecture on not. >> I'm not entirely convinced that that /is/ a reasonable request. It is >> perfectly reasonable to ask for it to be *at least* 16 bits. >> >> How, precisely, would you implement your exactly-16-bit type on a >> machine whose natural word size is 64? > > typedef struct Integer16 { signed value:16; } Integer16 ; That would make even simple addition rather tedious: Integer16 x = { 6 }; /* braces required */ Integer16 y = { 42 }; Integer16 z; z.value = x.value + y.value; Blech! -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ "Usenet is a strange place" - dmr 29 July 1999 Sig line vacant - apply within
From: Willem on 3 Jun 2010 12:54
Richard Heathfield wrote: ) Dann Corbit wrote: )> In article <2qmdnQNJioRrFZrRnZ2dnUVZ8nmdnZ2d(a)bt.com>, )> rjh(a)see.sig.invalid says... )>> How, precisely, would you implement your exactly-16-bit type on a )>> machine whose natural word size is 64? )> )> typedef struct Integer16 { signed value:16; } Integer16 ; ) ) That would make even simple addition rather tedious: ) ) Integer16 x = { 6 }; /* braces required */ ) Integer16 y = { 42 }; ) Integer16 z; ) ) z.value = x.value + y.value; How easy would it be to add that syntax to the language ? Something like: typedef signed value:16 Integer16; Or simply unsigned x:10 = 1000; unsigned y:10 = 42; unsigned z:10 = x + y; /* z is now 18 */ I'm not sure but I think that this is a syntax violation in C90/C99, so it could be added as a feature quite easily, no ? SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT |