42Bastian Schick wrote:> On 25 Jan 2005 15:38:47 GMT, Grant Edwards <grante@visi.com> wrote: > > >>On 2005-01-25, 42Bastian Schick <bastian42@yahoo.com> wrote: >> >>>On Tue, 25 Jan 2005 13:11:04 +0530, "Neo" >>><timeless_illusion@yahoo.com> wrote: >>> >>> >>>>Hi All, >>>> >>>>Is that true that size of a byte not necessarily 8-bit? >>> >>>I think common sense is that a byte is nowadays 8 bit. >> >>Common sense is often wrong. As yours seems to be in this >>case. I've worked on architectures where a byte (a-la "C") was >>32 bits. > > > > Maybe, or even sure, but if you read MBytes, KBytes etc. do you > honestly thing in 32-bit bytes ? > > > >>>That's it, they speak of words avoiding the term byte. >> >>The OP is asking about C. In C, 'byte' has a very specific >>definition. > > > Didn't know that C defines the term byte.http://en.wikipedia.org/wiki/Byte :-) -- E-Mail: Mine is an /at/ gmx /dot/ de address.
size of a byte and int?
Started by ●January 25, 2005
Reply by ●January 26, 20052005-01-26
Reply by ●January 26, 20052005-01-26
bastian42@yahoo.com (42Bastian Schick) wrote:> On 25 Jan 2005 15:38:47 GMT, Grant Edwards <grante@visi.com> wrote: > > >On 2005-01-25, 42Bastian Schick <bastian42@yahoo.com> wrote: > >> I think common sense is that a byte is nowadays 8 bit. > > > >Common sense is often wrong. As yours seems to be in this > >case. I've worked on architectures where a byte (a-la "C") was > >32 bits. > > Maybe, or even sure, but if you read MBytes, KBytes etc. do you > honestly thing in 32-bit bytes ?When I read megabytes et cetera, I do so in a hard drive spec, not in a C programming context. When programming, I don't use megabytes, I use precise numbers, and precise sizes. (Unhinted crossposts are evil.) Richard
Reply by ●January 26, 20052005-01-26
42Bastian Schick wrote:> > >> A reason, to define __u8,__u16,__u32 etc. > >> (or the like) depending on > >> the cpu and/or compiler. > > > >Leading underscores are for the implementation, > >not application programs. > > Eh, what do you mean by implementation ?A C implementation is whatever it takes to translate and execute a C program. If you have a compiler or a cross compiler, then that would be part of your implementation. -- pete
Reply by ●January 26, 20052005-01-26
On Wed, 26 Jan 2005 08:18:14 GMT, pete <pfiland@mindspring.com> wrote:>42Bastian Schick wrote: >> >> >> A reason, to define __u8,__u16,__u32 etc. >> >> (or the like) depending on >> >> the cpu and/or compiler. >> > >> >Leading underscores are for the implementation, >> >not application programs. >> >> Eh, what do you mean by implementation ? > >A C implementation is whatever it takes to translate and execute >a C program. >If you have a compiler or a cross compiler, >then that would be part of your implementation.Means, only the compiler or what comes with it should define types with leading underscores ? (Actually, IIRC I've seen in in some Linux source and found it appealing.) -- 42Bastian Do not email to bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@monlynx.de instead !
Reply by ●January 26, 20052005-01-26
On 25 Jan 2005 19:44:04 GMT, Grant Edwards <grante@visi.com> wrote:>I forgot to qualify my statement. IIRC, the spec says a byte >has to be at least 8 bits. A compiler designer may be allowed >to choose a byte size larger than an octet even if memory is >adderssable in octets. He'd be a bit daft, IMO, but it may be >legal...If the "the basic character set of the execution environment" is Unicode, it would make sense to define CHAR_BIT as 21, even if the processor would be capable of addressing 8 bit octets. In fact making 21 bit processors would not be a bad idea after all, since a single word could hold char, short and int values, while two words (42 bits) could hold long a float values and three words (63 bit) double values. Paul
Reply by ●January 26, 20052005-01-26
On Tue, 25 Jan 2005 19:59:22 -0000, "Peter" <moocowmoo@newprovidence.demon.co.uk> wrote:>Anybody else old enough to have worked on a machine with a 24 bit word and a >6 bit char? The first machine I learned assembler on was like that.I have not used 24 bit machines, but 36 bit machines with 6 or 9 bit characters.>With >only 6 bits something had to give, and so it couldn't use lower case >letters.What is the problem ? Who said that you could not use lowercase characters. It was up to the printing device if it produced all upper-case or all lower-case characters. In very early computers even 5 bit teletype codes has been used (with letter and digit shift codes). IIRC, some telex machines even printed the local keyboard entry in all upper-case and all text received from the line as all lower-case. Only a very small number of current programming languages and one family of operating systems make any distinction of upper and lower case characters anyway. However, a programming language with a much larger character set (such as Unicode) would be interesting, in which you could use e.g. greek characters as variable names when dealing with scientific entities or use a rich set of mathematical operators. The only language with such features I can think of was APL, but there may have been others. Paul
Reply by ●January 26, 20052005-01-26
42Bastian Schick wrote:> On Wed, 26 Jan 2005 08:18:14 GMT, pete <pfiland@mindspring.com> wrote: > > >>42Bastian Schick wrote: >> >>>>>A reason, to define __u8,__u16,__u32 etc. >>>>>(or the like) depending on >>>>>the cpu and/or compiler. >>>> >>>>Leading underscores are for the implementation, >>>>not application programs. >>> >>>Eh, what do you mean by implementation ? >> >>A C implementation is whatever it takes to translate and execute >>a C program. >>If you have a compiler or a cross compiler, >>then that would be part of your implementation. > > Means, only the compiler or what comes with it should define types > with leading underscores ?The compiler, the standard library, maybe the OS.> (Actually, IIRC I've seen in in some Linux source and found it > appealing.)This is not a matter of chic; if you use leading underscores, you are invading the implementation's namespace which can lead to nasty consequences. Imagine it was the other way round: The implementation would use i, j, k, count, num and others, so you cannot declare variables or functions of the respective names and be sure that everything works as intended as the implementation gives you macros which work on these global variables... Just have a look at the standard headers; you will probably find many underscores. If you inadvertently #undef'ed or #defined something which is needed there, then you might run into subtle trouble. Cheers Michael -- E-Mail: Mine is a gmx dot de address.
Reply by ●January 26, 20052005-01-26
Paul Keinanen wrote:>... snip ...> > However, a programming language with a much larger character set (such > as Unicode) would be interesting, in which you could use e.g. greek > characters as variable names when dealing with scientific entities or > use a rich set of mathematical operators. The only language with such > features I can think of was APL, but there may have been others.APL always was all greek to me :-) -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson
Reply by ●January 26, 20052005-01-26
Jim McGinnis <remove_this.mcginnis@and_this.ieee.org> wrote:> TI made some very interesting graphics processors about 15 years ago, > the 34010 and 34020. All their memory was bit-addressable and they had > an excellent C compiler, but with the quirk that the sizeof an 8-bit > char was 8, not 1.While it may have been excellent, it was not a "C compiler" by any meaningful definition of that term. If we were to accept such abuse of terms, we might as well call a Pascal compiler a "C compiler with somewhat buggy spelling".> This was the source of many bugs.I'd say this feature itself _was_ a bug. The "many bugs" are just different manifestations of this one central bug. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Reply by ●January 26, 20052005-01-26
"Peter" <moocowmoo@newprovidence.demon.co.uk> wrote in news:ct68eu$7h0$1$830fa7a5@news.demon.co.uk:> > "Neo" <timeless_illusion@yahoo.com> wrote in message > news:35mbgiF4pcd1dU1@individual.net... >> Hi All, >> >> Is that true that size of a byte not necessarily 8-bit? > > veering off topic a bit.... > > Anybody else old enough to have worked on a machine with a 24 bit word > and a 6 bit char? The first machine I learned assembler on was like > that. With only 6 bits something had to give, and so it couldn't use > lower case letters. > > Fortunately, they were all scrapped before they got around to > implementing C on them. >I remember working on one with a 60 bit word, then there were a couple I worked with just a few years back, one with a 140 bit word, the other with a 268 (or thereabouts) bit word, in both cases that was also the smallest addressable unit, other than single bits. -- Richard