Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.misc Subject: Re: 100 Things Date: Thu, 01 May 2014 16:08:34 -0400 Organization: Aioe.org NNTP Server Lines: 37 Message-ID: References: <3SQ7v.155346$AI5.24849@fx32.am4> <8muqscxvu33i$.22498hadddgj.dlg@40tude.net> <20140501112711.942@kylheku.com> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.misc:2119 On Thu, 01 May 2014 14:30:17 -0400, Kaz Kylheku wrote: > On 2014-05-01, BartC wrote: >> "Dmitry A. Kazakov" wrote in message >> news:yryqqrizlv6f$.brqhfwfl79vg.dlg@40tude.net... >>> On Thu, 1 May 2014 15:12:34 +0100, BartC wrote: >>>> That machines generally work in powers-of-two bitwidths is well-known. >>> >>> And those that don't, you program in another language... Right? >> >> Yes, exactly. C# supports 8, 16, 32 and (I assume) 64-bit data types, >> and so> does Java. > > These languages support *only* these types. > By "these languages", I'm assuming you mean C/C++ and derivatives. If so, you've been doing pretty good with your understanding of C, but not on that one. C doesn't define a byte as 8-bits as defined by the creators of EBCDIC and ASCII: Bob Bemer and Hugh McGregor Ross, and Dr. Werner Buchholtz who defined a byte as 8-bits. It defines a byte as the natural word size or minimal address unit of the machine or somesuch. I'm not going to re-read the specifications on this. E.g., most microprocessors have an 8-bit word size or address unit. So, for those machines, a byte and a char are 8-bits. They also typically have an integer that is an even multiple of 8-bits, e.g, 16-bits, 32-bits, etc. But, if we have a central processing unit (cpu) with a 16-bit minimum address unit, then a C byte is 16-bits, so is C's nul '\0' terminator. It must have all 16-bits cleared. This is to locate the end-of-string quickly without having to mask or unpack characters. This is documented in one of Ritchie's papers. However, a char on such a machine could be 8-bits, for two char's per C byte, or it could be 9-bits etc with only one char per C byte. Rod Pemberton