Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.misc > #2114

Re: 100 Things

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.misc
Subject Re: 100 Things
Date 2014-05-01 18:26 +0000
Organization Aioe.org NNTP Server
Message-ID <20140501111726.159@kylheku.com> (permalink)
References (5 earlier) <8muqscxvu33i$.22498hadddgj.dlg@40tude.net> <QYo8v.132019$Xl1.16531@fx09.am4> <i8gmjwf2beyz.12f8p3m5cxcnh$.dlg@40tude.net> <qDs8v.300080$Kx7.12720@fx26.am4> <yryqqrizlv6f$.brqhfwfl79vg.dlg@40tude.net>

Show all headers | View raw


On 2014-05-01, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
> On Thu, 1 May 2014 15:12:34 +0100, BartC wrote:
>
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
>> news:i8gmjwf2beyz.12f8p3m5cxcnh$.dlg@40tude.net...
>>> On Thu, 1 May 2014 11:02:17 +0100, BartC wrote:
>> 
>>>> At the level we're talking about, generally we know the hardware can deal
>>>> with integer values that are 8, 16, 32 or 64 bits wide, and floating point
>>>> values that are 32 or 64 bits. (There might be a few extra odd ones such
>>>> as 80-bit floats, or software-supported 128-bit ints.)
>>>>
>>>> One way of choosing whether to use 8, 16, 32 or 64 bits for a storage
>>>> type (for storing data in memory), is to actually specify 8, 16, 32, or [64]
>>>> bits! It can't get any simpler.
>>>
>>> What do you do when there is no given machine type? Let you compile for
>>> 32-bit i686. There is no 64-bit integer. Wait, there is but you need
>>> special instructions. It is not the way to deal with this. You don't make
>>> the language semantics dependent on the target machine.
>> 
>> That machines generally work in powers-of-two bitwidths is well-known.
>
> And those that don't, you program in another language... Right?

Anyway, C doesn't specify bitwidths that are powers of two. In fact,
it originally ran on some machines that had 18 bit ints.

C specifies minimum sizes for certain types. The CHAR_BIT preprocessor constant
gives how many bits are in a signed or unsigned char (and therefore byte).
It is at least eight but doesn't have to be. Example: IBM mainframes
with 9 bit bytes, and 36 bit words.

Since C99, C also has some exact width types in popular power-of-two-bits sizes
like int32_t, declared as a typedef in a header. Since this might not be
available, there is a way to test for it at preprocessing time.

C code that needs, say, 32 bit two's complement arithmetic, and run on any
machine, just needs to use an unsigned type which is at least 32 bits wide,
mask down results to fall into that range, and interpret bit 31 as a sign bit.

In C, you can easily write, say, an emulator for the Motorola 68000 that will
run anywhere there is an ISO conforming compiler which can accept a program
that large, targetting a machine with enough resources to run it.

Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C: 100 Things "BartC" <bc@freeuk.com> - 2014-04-29 17:57 +0100
  Re: 100 Things "James Harris" <james.harris.1@gmail.com> - 2014-04-30 07:40 +0100
    Re: 100 Things "BartC" <bc@freeuk.com> - 2014-04-30 12:16 +0100
      Re: 100 Things "James Harris" <james.harris.1@gmail.com> - 2014-04-30 13:54 +0100
        Re: 100 Things "BartC" <bc@freeuk.com> - 2014-04-30 14:39 +0100
          Re: 100 Things "James Harris" <james.harris.1@gmail.com> - 2014-04-30 20:18 +0100
            Re: 100 Things "BartC" <bc@freeuk.com> - 2014-04-30 22:40 +0100
              Re: 100 Things Kaz Kylheku <kaz@kylheku.com> - 2014-04-30 22:09 +0000
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-04-30 23:36 +0100
                Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-01 11:03 +1200
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 09:47 +0100
              Re: 100 Things "James Harris" <james.harris.1@gmail.com> - 2014-05-01 00:35 +0100
                Re: 100 Things Andy Walker <news@cuboid.co.uk> - 2014-05-01 11:03 +0100
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 20:16 +0100
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 12:44 +0100
                Re: 100 Things "James Harris" <james.harris.1@gmail.com> - 2014-05-02 11:11 +0100
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-02 13:32 +0100
                Re: 100 Things "James Harris" <james.harris.1@gmail.com> - 2014-05-02 16:42 +0100
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-02 17:54 +0100
          Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-01 11:01 +1200
      Re: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-04-30 21:13 -0400
        Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 09:26 +0100
          Re: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-01 16:08 -0400
      Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-01 13:42 +1200
        Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 09:35 +0100
          Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-01 21:02 +1200
            Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 10:40 +0100
              Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-01 22:06 +1200
          Re: 100 Things "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-01 11:08 +0200
            Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 11:02 +0100
              Re: 100 Things "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-01 13:57 +0200
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 15:12 +0100
                Re: 100 Things "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-01 17:18 +0200
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 17:04 +0100
                Re: 100 Things Kaz Kylheku <kaz@kylheku.com> - 2014-05-01 18:30 +0000
                Re: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-01 16:08 -0400
                Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-02 08:30 +1200
                Re: 100 Things George Neuner <gneuner2@comcast.net> - 2014-05-03 01:29 -0400
                Re: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-03 02:37 -0400
                Re: 100 Things George Neuner <gneuner2@comcast.net> - 2014-05-03 15:39 -0400
                Re: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-03 17:30 -0400
                Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-04 20:05 +1200
                Re: 100 Things George Neuner <gneuner2@comcast.net> - 2014-05-04 13:28 -0400
                Re: 100 Things Ian Collins <ian-news@hotmail.com> - 2014-05-05 07:40 +1200
                Re: 100 Things "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-01 22:00 +0200
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-01 23:24 +0100
                Re: 100 Things "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-02 08:59 +0200
                Re: 100 Things "BartC" <bc@freeuk.com> - 2014-05-02 09:53 +0100
                Re: 100 Things "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-02 11:22 +0200
                Re: 100 Things Kaz Kylheku <kaz@kylheku.com> - 2014-05-01 18:26 +0000
                Re: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-01 16:08 -0400
                Re: 100 Things Kaz Kylheku <kaz@kylheku.com> - 2014-05-02 02:49 +0000
  Re: C: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-04-30 22:08 -0400
  Re: C: 100 Things "BartC" <bc@freeuk.com> - 2014-07-25 23:53 +0100
    Re: C: 100 Things "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-26 05:38 -0400
      Re: C: 100 Things "BartC" <bc@freeuk.com> - 2014-07-26 13:51 +0100
        Re: C: 100 Things rick.c.hodgin@gmail.com - 2014-10-25 04:48 -0700
  Re: C: 100 Things "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2014-10-25 04:50 -0700

csiph-web