size of a byte and int? - Page 3

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: size of a byte and int?
Quoted text here. Click to load it

There *was* at least one 1100-series C compiler.  I never used it,
but I know people who did.  The compiler had 9-bit "char" (ASCII
quaterword, as you would expect), 18-bit "short", and 36-bit "long".
I think, but am not sure, that "int" was also 36 bits.  All were
of course ones' complement.

(This predated the 1989 C Standard, and I imagine various things
the compiler did would not have been conforming.  Note, however,
that ones' complement is explicitly allowed.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W)  +1 801 277 2603
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?

Quoted text here. Click to load it


Maybe, or even sure, but if you read MBytes, KBytes etc. do you
honestly thing in 32-bit bytes ?


Quoted text here. Click to load it

Didn't know that C defines the term byte.


--
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
Quoted text here. Click to load it

http://en.wikipedia.org/wiki/Byte :-)

--
E-Mail: Mine is an   /at/ gmx /dot/ de   address.

Re: size of a byte and int?

Quoted text here. Click to load it

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

Re: size of a byte and int?

Quoted text here. Click to load it

No but that's moot. The OP was asking about C programming.

Quoted text here. Click to load it

I hope you don't write C programs.

--
Grant Edwards                   grante             Yow!  Could I have a drug
                                  at               overdose?
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
Quoted text here. Click to load it

C defines a number of words like "object" and "string", which
have slightly different meanings in other programming contexts.

--
pete

Re: size of a byte and int?
Quoted text here. Click to load it

I do, but prefer assembler :-)
--
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
snipped-for-privacy@yahoo.com (42Bastian Schick) wrote in

Quoted text here. Click to load it

Leading underscores are for the implementation, not application programs.



--
- Mark ->
--

Re: size of a byte and int?

Quoted text here. Click to load it

Eh, what do you mean by implementation ?

And what is an application in this regard ?

Is a TCP/IP stack an application in this sense ?

I am confused !

--
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
Quoted text here. Click to load it

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

Re: size of a byte and int?

Quoted text here. Click to load it


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 snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
Quoted text here. Click to load it

The compiler, the standard library, maybe the OS.

Quoted text here. Click to load it

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.


Re: size of a byte and int?
Quoted text here. Click to load it

Means "the implementor" -- the guy writing your compiler and
surrounding code.

Quoted text here. Click to load it

Suppose I, as your implementor, put this in <stdio.h> (contrary to
the standard's requirement that I do not do this):

    #define i 42
    #define tmp "ha ha"

Now you, the user, write your program, including a function:

    #include <stdio.h>
    ...
    void f(...) {
        int i;
        char *tmp;
        ...

When you go to compile this, the compiler "sees" the top of your
function f() written as:

        int 42;
        char *"ha ha";

and gives you a bunch of strange syntax error messages.

I, the implementor, keep out of you way by making sure I do this:

    /* flags for __sflag field */
    #define __SRD 1
    #define __SWR 2
    [etc]

You, the user, keep out of my way by not using names like "__SRD".
For the most part, all the names starting with "_" are mine, and
all the rest are yours.  If I define "i" or "tmp", it is my fault
for breaking your code.  If you define _ZOG, it is your fault for
breaking my code.

Now, what if you are neither the implementor, nor the end user?
What if you are the guy writing a library for doing graphics, or
playing chess, or whatever?  What names do *you* get?  (The Standard
answereth not.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W)  +1 801 277 2603
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
Quoted text here. Click to load it

Which is all nice and clear for those not yet aware.  As far as the
last paragraph is concerned, common practice is to add a
(hopefully) unique prefix to all names in that library.  Some use
prefix, underscore, and then the normal name, as in "hsh_find".  I
leave out the underscore.  With luck it all works.

--
"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
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
Quoted text here. Click to load it

Now, that's clear. Thanks.



--
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?
[F'up2 cut down --- should have been done by OP!]


Quoted text here. Click to load it

You cross-posted this question to two newsgroups, one of which (c.a.e)
it is seriously off-topic in.  Please don't do that, or if you do, at
least explain why, and set a Followup-To.  As is, your posting
silently assumes a context that only applies to half your audience,
causing all kinds of needless confusion.

In the context of comp.arch.embedded, your question doesn't make much
sense at all.  In the context of comp.lang.c, the answers to the above
are: Yes.  The same.  Implementation-defined.  (In that order).

Your confusion seems to come from the fact that you don't realize that
sizeof(int), too, is implementation-defined (within limitations set up
by the standard on the range of values an int must at least be able to
hold).  In theory, an implementation could have, say

    CHAR_BITS    == 13
    sizeof(short)    == 2
    sizeof(int)    == 3
    sizeof(long)    == 5
    sizeof(float)   == 7
    sizeof(double)  == 9

just for the perverse fun of it.

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: size of a byte and int?

Quoted text here. Click to load it

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.

Peter



Re: size of a byte and int?

Quoted text here. Click to load it

No, but I did some homework assignments on a machine with a 60
bit word and a 6 bit char.

--
Grant Edwards                   grante             Yow!  BRILL CREAM is
                                  at               CREAM O' WHEAT in another
We've slightly trimmed the long signature. Click to see the full one.
Re: size of a byte and int?

Quoted text here. Click to load it

As I mentioned up-thread: 36-bit word, 6-bit character (most often --
wider character encodings could be used).

Regards,

                               -=Dave
--
Change is inevitable, progress is not.

Re: size of a byte and int?

Quoted text here. Click to load it

No, I started on core memory, but never got realy close to odd
wordlength (did some high-level programming with 60 bit words, but
don't remember the size of a char - it was academic) until the early
90's on an AD DSP with 24 bit word's. I settled on packed 6 bit chars
with a teletype-like upper/lowercase escape sequence in an external
display.

Andreas
--
"My name is Dump, Core Dump"

Site Timeline