delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/26/13:41:46

From: Radical NetSurfer <radsmail AT juno DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: BAD strupr, BAD getw
Date: Fri, 25 Aug 2000 21:07:16 -0400
Message-ID: <ad5eqsg3sdfgl0ciid50au76t09e78h51n@4ax.com>
References: <2mncqsos70c6u5losbrrlrq9qq2esrm9t0 AT 4ax DOT com>
X-Newsreader: Forte Agent 1.8/32.548
X-No-Archive: yes
MIME-Version: 1.0
NNTP-Posting-Host: 216.202.134.232
X-Original-NNTP-Posting-Host: 216.202.134.232
X-Trace: 25 Aug 2000 21:10:13 -0400, 216.202.134.232
Lines: 93
X-Original-NNTP-Posting-Host: 64.31.79.51
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

/Begin RadSurfer Reply/
OK! Enough dancing with strangers, lets get down to being pardners! :)

I'd like to know your favorite books on this subject; noteworthy
magazaine articles, whatever you might wish to share. Thanks.

QUESTION:
If one wanted to know the PROPER terminology for x-bit-sized
quantities, WHERE would they look, and WHAT would they find?
SUCH THAT one could write a SINGLE program statement and have
it properly interpreted (at least on some common ground level) as
expected?

As in my previous message:

NIBBLE       4 bits          Example: 1 single BCD 

Alternative/Universal 4-Bit Term is: __________________________

BYTE           8 bits         Example: "typical single character"
Depending on Platform:   WORD/2, WORD/4, etc. (sheesh!) 
                                         
Alternative/Universal  8-BitTerm is: ___________________________

"SHORT"      16 bits        Example: 
                    In some platforms (WORD/2)
Alternative: pc16WORD, SHORT, "HALF_WORD"
                   Universal 16-Bit Term is: ________________________

WORD         32 Bits         Example: 
Typically 16, Alternatively 32.
Universal 32 Bit Term: ________________
The ques HERE, at this point should be OBVIOUS:
If we define a WORD as 32 bits, what _TERMINOLOGY_ is used
to define a  16-bit value (this I've never seen explained), 
"HALF_WORD", and "SHORT" are contrivinces for convenience sake.

DWORD       2xWORD   Example:
Alternatives/Universal  64-Bit Term:
Alternative/Universal 2xWORD Term:

At this point, things really get quite icky indeed :(
(We never got into discussing what Terminology is used to define
 specific BIT_FIELD's; and yes, they do have specific names; and its
useful for them to even have names.) 

Thank you, industry people, for making it all so very clear to us all.

/End RadSurfer Reply/
----------------------------------------------------------------------------------------------------
Eli Zaretskii wrote:

> I don't see any problem here: simply put the result of getw into a
> short variable, and you are done.  getw *does* read only 16 bits from
> the file, it just returns it in an int, that's all.  But the upper
> bits of that int are not used (except for sign-extension, for negative
> values).  So you *do* get a short, as you should.

This is wrong: getw() reads 32 bits.  This is what it does in
Borland C++ 5.5 as well, so it's clearly not a mistake.  Here's
the source (which for some reason is in src\libc\ansi\stdio):

#include <stdio.h>
#include <libc/file.h>

int
getw(FILE *f)
{
  int i;
  char *p;
  int w;

  p = (char *)&w;
  for (i=sizeof(int); --i>=0;)
    *p++ = getc(f);
  if (feof(f))
    return EOF;
  return w;
}

---------------------------------------------------------------------------------------------------
/* RadSurfer's initial thoughts:
Ah, Mr. Wizard, sir, has it not been mentioned already, no one has
defined these terms "universally" yet? for whatever rediculous and
obscure reason that may be; humans tend to take certain areas of
disciplines and simply ignore the obvious need to consolidate things.
(they seem to have much more fun fighting over themselves about
 the issues in question; rather than organizing them; (flux))
*/

Email is welcomed (even yours): radsmail AT juno DOT com
http://members.tripod.com/~RadSurfer/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019