HDTenEightyP/NetNews huggingface dataset:
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: comp.lang.c
Subject: Re: WANTED: Fast addition for 64-bits integers in C
Date: 1 Jan 93 02:55:44 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Organization: University of Arizona

In article <1992Dec31.142337.28023@donau.et.tudelft.nl>, arlet@einstein (Arlet Ottens) writes:
>I want to make an implementation of 64-bit integers in C, using
>a pair of 32-bit integers.

If speed is your over-riding concern, use assembly language.  Unfortunately,
this has several aspects that make it otherwise undesirable:

    -it's utterly unportable
    -since speed is assumed to be a factor, you'll probably
     want to define the various operations as macros as faux-inline
     functions; unfortunately, many assembly language interfaces
     work poorly or not at all with the preprocessor.

Another alternative is to do something like this:

#define N_LONG_BYTES 8 /* or whatever */

/* wrapping it in a struct allows you to pass it around using
 * call-by-value semantics.  This has the advantage that you
 * don't have to do dynamic allocation for every discrete value.
 * The disadvantage, of course, is that copying bytes can get
 * expensive...
 */
typedef struct { unsigned char bytes[N_LONG_BYTES] ; } hyper_long ;

hyper_long hl_add( hyper_long, hyper_long ) ;
hyper_long hl_sub( hyper_long, hyper_long ) ;
hyper_long hl_mul( hyper_long, hyper_long ) ;
hyper_long hl_div( hyper_long, hyper_long ) ;

hyper_long hl_add( hyper_long a, hyper_long b ) {

  int i, sum ; hyper_long c ;

  for( i = 0 ; i < N_LONG_BYTES ; i++ ) c.bytes[i] = 0x00 ;
  for( i = 0 ; i < N_LONG_BYTES ; i++ ) {
    sum = a.bytes[i] + b.bytes[i] ; c.bytes[i] += 0xff & sum ;
    if( sum > 0xff )
      if( i+1 < N_LONG_BYTES ) c.bytes[i+1] = 1
      else Hyper_Long_Error = HL_OVERFLOW_IN_ADD ;
    }

  return c ;
  }

/* similarly for hl_sub, hl_mul, hl_div, etc... */
/* I haven't tested the above code so Use At Your Own Risk. */
  

Of course, this wouldn't be as fast as an assembly language solution, but
it could be made portable.  Hmm... in fact, one might even do something
like

typedef struct {
  unsigned char *bytes ;
  unsigned int  nbytes ;
  } hyper_long ;

So that you could decide on-the-fly how many bytes you want.  Of course,
this would require an explicit allocation routine.  If this solution
appeals to you, you might want to consider writing your application
in C++, which would automatically call your allocation routine, as
well as allow you to expand the definitions of all the arithmetic
operators to include the "hyper_long" type.

The only other option that comes to mind is to switch to yet another
language like Lisp, which has support for very large numbers built in.

-- 
What I've learned from reading net news #1:
  It's important to do a lot of outside reading, because you never know
  where you might come across a clever quote you can use in your .sig file.
From: omarab@atlantis.CS.ORST.EDU (Scorpion)
Newsgroups: comp.lang.c
Subject: Re: Directory search function needed
Date: 1 Jan 93 22:45:46 GMT
Organization: OSU CS Outreach Services, Corvallis, Oregon
NNTP-Posting-Host: atlantis.cs.orst.edu

OK.... I had been interested in such a file search program too.... This
example is found in the THELP program which is supplied with Turbo C:

#include "c:\borland\include\dir.h"
#include "c:\borland\include\stdio.h"

void main()
{
struct ffblk ffblk;
int done;

done = findfirst("*.*", &ffblk, 0);
while(!done)
  {
  printf("%s\n", ffblk.ff_name);
  done = findnext(&ffblk);
  }
}

That should do it for ya dude.... the findfirst command is the one you will
use... allong with the findnext command.  Hope that helps ya out....

-----------------------------------------------------------------------------
 Brendan O'Mara					Owner, Stealth Technologies,
 Email: omarab@jacobs.ucs.orst.edu		specializing in:
 Alias: Scorpion					
 Phone: (503)745-7549				Programming
						Computer Lessons
 Sysop of the Stealth BBS:			Computer Setup Assistance
 (503)745-7549, 9pm-7am weekdays,			
 24 hours most weekends.			Call for details!
------------------------------------------------------------------------------
-- 
-----------------------------------------------------------------------------
 Brendan O'Mara					Owner, Stealth Technologies,
 Email: omarab@jacobs.ucs.orst.edu		specializing in:
 Alias: Scorpion					
Newsgroups: comp.lang.c
From: rick.franks@hal9k.ann-arbor.mi.us (Rick Franks) 
Newsgroups: comp.lang.c
Subject: NEW MEMBER
Date: 24 Dec 92 13:13:00 GMT
Distribution: world
Organization: HAL 9000 BBS, (313)663-4173, Ann Arbor, MI, USA
Reply-To: rick.franks@hal9k.ann-arbor.mi.us (Rick Franks) 

The folks down here in Myrtle Beach SC, would like to say hello
to you up in W-NET. And would like to inform you'all we are now
cross-linking this confernece with our own BUM_NET network.
Have a Merry Christmas and a Happy New Year...
---
 . Cam-Mail . The Chess Board BBS - Home of BUM_NET Network, MB, SC
From: d90-awe@klara.nada.kth.se (Assar Westerlund)
Newsgroups: comp.lang.c
Subject: Re: Parameter passing & data abstraction
Date: 1 Jan 93 03:42:31 GMT
	<1993Jan1.002606.13612@organpipe.uug.arizona.edu>
Organization: Royal Institute of Technology, Stockholm, Sweden

In article <1993Jan1.002606.13612@organpipe.uug.arizona.edu> dave@cs.arizona.edu (Dave Schaumann) writes:

   In article <24524@alice.att.com>, bs@alice (Bjarne Stroustrup) writes:
   >
   >
   >dave@cs.arizona.edu (Dave Schaumann @ University of Arizona) writes
   >
   > [I complained about the large size executables g++ produces]
   >
   >That cannot be a C++ problem. For
   >
   >	#include <stdio.h>
   >
   >	main() { printf("Hello, World\n"); }
   >
   >I get 
   >
   >	text	data	bss	dec	hex
   >	12288	6144	7624	26056	65c8
   >when compiling as a C++ program, and
   >
   >	text	data	bss	dec	hex
   >	12288	6144	7612	26044	65bc

   OK, fair enough.  Here's what I get:

   Machine    gcc size    g++ size  (size in bytes)
   -------    --------    --------
   Sequent      18085       23882
   Sun 4        24576      110490(!)

Better use size as Bjarne does. libg++ is usually compiled with
debugging-information included, which usually takes place on disk but
not in memory (unless you use a debugger, of course).

I get:

klara:>size /tmp/test.g{++,cc}
text    data    bss     dec     hex
8192    8192    0       16384   4000    /tmp/test.g++
8192    8192    0       16384   4000    /tmp/test.gcc

On a sun4 using GCC/G++ 2.3.2.
Newsgroups: comp.lang.c
From: rsaripa@bach.cs.clemson.edu (Saripalli Ramakrishna)
Subject: Information about pragma directives
Keywords: C language,ANSI C
Organization: Clemson University Computer Science Dept.
Distribution: na
Date: Wed, 30 Dec 1992 22:57:57 GMT

Hi there,

	Can someone send me some sample C code or some piece of information regarding the use of
	pragma directives in C(ANSI C)?.What are they really used for?.

	I really appreciate it.


							Thanks in advance,
							Ramakrishna Saripalli


Man is a beast and usually has no control over his passions.
Newsgroups: comp.lang.c
From: root@cpp.uucp (Rich Bauer)
Subject: FP formats not linked
Organization: Critical Path Project
Date: Wed, 30 Dec 1992 02:35:47 GMT

When scanf goes to get the first batting average in this program,
the program terminates abnormally with the error message:
"floating point formats not linked"

What does this mean?  I can't find it in the manuals, and the code
is correct as far as I can tell.  What's the problem?

----------------------------------------------------------------------

#include <stdio.h>

void main(void)
{
	char name[9] [80];
	double b_avg[9];
	int i, h, l;

	double high, low, team_avg;

	for(i=0;i<9;i++) {
	  printf("Enter name %d: ", i+1);
	  scanf("%s",name[i]);
	  printf("Enter batting average: ");
	  scanf("%lf", &b_avg[i]);
	  printf("\n");
	}
	high=0.0;
	low=1000.0;
	team_avg=0.0;
	for(i=0;i<9;i++) {
	  if(b_avg[i]>high) {
	  h=i;
	  high=b_avg[i];
	  }
	  if(b_avg[i]<low) {
	  l=i;
	  low=b_avg[i];
	  }
	  team_avg=team_avg+b_avg[i];
	}

	printf("The high is %s %lf\n",name[h],b_avg[h]);
	printf("The low is %s %lf\n",name[l],b_avg[l]);
	printf("The team average is %lf",team_avg/9.0);
}


-- 
Rich Bauer	   	   |	UUCP...!dsinc!jabber!cpp!rich
Critical Path Project Inc  |	or.....rich@cpp.UUCP
Philadelphia PA            |    Public Access, News & Mail 
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Qusetions about UC Berkerley header file. Help!
Organization: Computer Science, University of Melbourne, Australia
Date: Mon, 28 Dec 1992 10:27:18 GMT

ren@function.mps.ohio-state.edu (Liming Ren) writes:

>This question bugs me all the day. I hope it makes sense.
>
>I am reading two header files distributed by UC Berkley. One is search.h
>and the other one is db.h (they are about hashing, Btree etc).
>
>(1) In search.h, there are several lines such as:
>
>int      hcreate __P((unsigned int));
>void     hdestroy __P((void));
>ENTRY   *hsearch __P((ENTRY, ACTION));
>
>I don't understand this. It seems __P is a function returns ....(confused 
>here).  What are hcreate , hdestroy etc anyway?

__P will actually be a *macro*, defined by something like this:

	#ifdef __STDC__
	#define __P(decl) (decl)	/* Use ANSI prototypes */
	#else
	#define __P(decl) ()		/* Use old-style declarations */
	#endif

The idea here is to be able give one declaration for each function, 
using the __P macro so that it works for both ANSI C and K&R C.
For ANSI C, the declaration for hcreate() will expand to
	int hcreate (unsigned int);
and for K&R C it will expand to
	int hcreate ();

>(2) In db.h, there is a definition for  DB:
>
>typedef struct __db {
>        DBTYPE type;                    /* underlying db type */
>        int (*close)    __P((struct __db *));
>        int (*del)      __P((const struct __db *, const DBT *, unsigned int));
>        int (*get)      __P((const struct __db *, const DBT *, DBT *,
>                            unsigned int));
>        int (*put)      __P((const struct __db *, const DBT *, const DBT *,
>                            unsigned int));
>        int (*seq)      __P((const struct __db *, DBT *, DBT *, unsigned int));
>        int (*sync)     __P((const struct __db *));
>        void *internal;                 /* access method private */
>} DB;

This declares a structure which contains various pointers to functions.
For example, given
	DB x;
then x.close is a pointer to a function taking a pointer to struct __db and
returning an int.
(Pointers in structures like this are generally used in C to do the same sort
of things that can be achieved with virtual functions in C++.)

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
From: pdh@netcom.com (Phil Howard )
Newsgroups: comp.lang.c
Subject: Re: definition of strncpy stupid?
Date: 31 Dec 92 01:44:13 GMT
Organization: Netcom - Online Communication Services  (408 241-9760 guest)

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:

>I've seen a "student" Fortran compiler on a slow machine outperform a
>"professional" optimizing Fortran compiler on a faster machine simply
>because the "student" compiler compiled FORMAT statements (and it gave
>better run-tiume diagnostics too, good one Dr Fenwick).  The same could
>be done for C, and it WOULD be done if enough people demanded it with
>their wallets in their hands.

The trouble is, those who have their hands on the wallets are not the ones
that know what to demand.  This is why a substantial number of software
products on the market are lacking in quality.
-- 
/************************************************************************\
| Phil Howard,  pdh@netcom.com,  KA9WGN    Spell protection?  "1(911)A1" |
| "It's not broken... it's just functionally challenged" --Phil and Pete |
\************************************************************************/
Organization: Penn State University
Date: Tue, 29 Dec 1992 13:34:07 EST
From: <EPA100@psuvm.psu.edu>
Newsgroups: comp.lang.c
Subject: date format

I am trying to write a simple program in turbo c and can not for the life of me
figure out how to do it. what I am attempting is as follows

struct dat{
  int dayr;     /* struct to get the date from the system through dos.h*/
 char damo;
 char dada;
 } da

getdate(&da);
printf("%i\n", da.dayr);
printf("%s\n", da.damo);
etc...
I am able to get the year 1992, but when I attempt to print the month and day I
get the Borland copyright info printing on the screen. I am not sure whether or
not this is even the correct way to go about it. I am a novice at C but would j
ust like to deconstuct the entire date into it's component parts and use them.
Thanks in advance

Ed
Newsgroups: comp.lang.c
From: mcastle@cs.umr.edu (Michael R Castle)
Subject: Re: [FAQ] size of executables ?
Date: Sun, 3 Jan 1993 07:14:30 GMT
Organization: University of Missouri - Rolla, Rolla, MO

In article <93003.004225RVK@psuvm.psu.edu> <RVK@psuvm.psu.edu> writes:
>Hi, my question may be a faq, but I am asking it nevertheless.
>
>How does one compile a c program so that the size of the
>executable is as small as possible. I noticed that even a
>trivial program like Hello.c  produces a huge executable,
>perhaps due to the include files stdio.h etc. Of course,
>I can not do any i/o without stdio.h . On the other hand,
>I am not using all the stuff that's there in stdio.h, and
>feel that the size of the executable should be proportional
>to what I am using. Any suggestions ?

printf() is huge.  Anyprogram that uses printf() has the potential for creating
a large exectuable.

Try this:

#include <stdio.h>

int main(void) {
  printf("line 1\n");
}


then:

#include <stdio.h>

int main(void) {
  printf("line 1\n");
  printf("line 2\n");
}


Compare the size of the executables.  Probably pretty close.  It's not so
much how many function calls, but what functions you are calling.

I imagine puts() is much smaller than printf().

Try

#include <stdio.h>

int main(void) {
  puts("line 1\n");
}

And see if that is any smaller than using printf().

Of course, then you loose functionallity.

You could try to simulate printf() functionallity using sscanf() and puts()
but I imagine sscanf is nearly as large as printf() so you wouldn't get 
anyway. (Maybe both link in the same code?)

Anyway, smart linkers (like Borlands) does try to link in only function that
are actually called, so not all the functions listed in stdio.h are linked in.

Matter of fact, man compiler (at least on unix systems) are putting more and
more of all the prototypes into one (large) .h file.  I imagine the original
reason for not including all the of the standard system libs into one large
file in the first place was because of slower systems.  Filtering out all the
stuff in the .h file you don't actually use was too slow.  Now days, compilers
are usually fast enough that that extra overhead is not noticable (of course,
this limits defining your own functions that have the same name, but oh
well).

enough ramblings,
mrc
-- 
Mike Castle .-=NEXUS=-.  Life is like a clock:  You can work constantly
  mcastle@cs.umr.edu     and be right all the time, or not work at all
S087891@UMRVMA.UMR.EDU   and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen
Newsgroups: comp.lang.c
From: adykes@jpradley.jpr.com (Al Dykes)
Subject: Conversion of Lattice C to Microsoft C ???
Date: Wed, 30 Dec 1992 20:31:27 GMT
Organization: Unix in NYC

I'm about to be asked to convert a large application from
Lattice C to a viable C compiler, the default is Microsoft C
but we might consider another brand if it aided the conversion.

The application uses Lattice's own B-tree/ISAM package, I'm told.  Is 
there a third-party B-tree package that is call-compatible with Lattice's
package ?

We intend to replace the DOS character mode interface C code with a
MS-Windows GUI tool, possibly Visual Basic, while keeping as much of
the business logic code as possible. The surviving C code will be
compiled into DLLs.

What are the issues with Lattice-to-Microsoft C conversion ?  If there
are differences has anyone developed a tool to automate the conversion ?

Any advise is appreciated.

Al Dykes
---------
adykes@jpr.com
From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 30 Dec 92 20:51:55 GMT
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development

In article <m5TiwB1w165w@quest.UUCP>, kdq@quest.UUCP (Kevin D. Quitt) writes:
|> mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
|> >In <wsP8VB1w165w@quest.UUCP>kdq@quest.UUCP (Kevin D. Quitt) writes:
|> >>mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
|> >>>sizeof(4["this is a test"])
|> >>>must produce 1, or your compiler's broken.
|> >>
|> >>   Either that, or you've got 16-bit chars.
|> >
|> >sizeof(char) is defined to be 1, so it doesn't matter if you have
|> >16-bit chars or not; it still better give back a 1.
|> 
|>     Interesting.  The standard states (3.3.3.4) that sizeof returns the
|> size of an object in bytes (exclusive of function and incomplete

"Bytes" in this context are identical to "chars". Bytes contain an
implementation defined number of bits according to the definition
of terms. The standard certainly supports the 16bit character. Its "size"
according to "sizeof", however, is still 1. Such an implementation has
16bit bytes.

|> types), and also states that the sizeof any qualified char is 1.
|> 
|>     Apparently, while they support multi-byte characters, as strings
|> (and provide functions for them), they don't directly support the 16bit
|> character.  Hmm...
|> 
|> 
|> 
|>  _
|> Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq

-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
Newsgroups: comp.lang.c
From: peter@deepthought.unm.edu (Peter Blemel)
Subject: Why would someone put 'char x[]' inside of a struct decl?
Date: Fri, 01 Jan 93 02:52:27 GMT
Organization: Disorganization

I'm trying (really I am) to write a Microsoft Windows app, and I've come across
a structure (Prog ref, vol 4 pg90) that looks something like...

struct DialogBoxHeader {
	.
	.
	.
	char szMenuName[];
	.
	.
	char szFaceName[];
};

First, this reference sucks. It doesn't explain how to use this and a companion
structure (on the following page) together. Second, I can't figure out how to
initialize this structure(?). szMenuName isn't allocated any storage, and I can't
allocate any for it because it's not a lvalue. 

Has Windows finally driven me over the edge? Am I crazy? Is there a way to initialize
this structure?

None (0) of the reference books I own (Including Petzold, all the Prog. Ref. Lib, 
and about 4 other books) discusses how to use DialogBoxIndirect(). I did find in
one of my 3.0 manuals (the Microsoft Prog. Ref. Manuall) says the second structure
must follow 'the terminating null of the szFaceName element'. Does this mean that
this isn't really a struct at all, but just a bunch of data stuffed into memory one
after another, with szMenuName, szFaceName, etc varying in length and the elements
that follow them just sitting after their terminating '\0's? (If you ask me, that
is _not_ a structure, and _certainly_ shouldn't be "documented" with C syntax!)

Lobotomized minds want to know...

Peter
From: bs@alice.att.com (Bjarne Stroustrup)
Newsgroups: comp.lang.c
Subject: Re: Parameter passing & data abstraction
Date: 31 Dec 92 05:18:48 GMT
Article-I.D.: alice.24524
Organization: AT&T Bell Laboratories, Murray Hill NJ



dave@cs.arizona.edu (Dave Schaumann @ University of Arizona) writes

 > Another would be to switch to C++, but I'm not especially keen to do that,
 > in part because the resulting executable (at least for g++) tend to be
 > 300+K in size, even for fairly simple programs.

That cannot be a C++ problem. For

	#include <stdio.h>

	main()
	{
		printf("Hello, World\n");
	}

I get 

	text	data	bss	dec	hex
	12288	6144	7624	26056	65c8
when compiling as a C++ program, and

	text	data	bss	dec	hex
	12288	6144	7612	26044	65bc

when compiling as a C program. Changing the example to use
specific C++ facilities
	
	#include <iostream.h>

	main()
	{
		cout << "Hello, World\n";
	}

I get

	text	data	bss	dec	hex
	17408	2048	0	19456	4c00


Ofcourse G++ may be different, but that difference ought to
show up in GNU C also, then
From: omarab@atlantis.CS.ORST.EDU (Scorpion)
Newsgroups: comp.lang.c
Subject: OUTPORT command... NEED HELP FAST!! EMAIL RESPONCE!
Summary: I NEED SOME HELP!!!!!!
Keywords: outport help C C++ I/O ports outp outportb
Date: 2 Jan 93 00:21:33 GMT
Article-I.D.: leela.1i2n6dINNqlc
Distribution: world
Organization: OSU CS Outreach Services, Corvallis, Oregon
NNTP-Posting-Host: atlantis.cs.orst.edu


I AM IN NEED OF HELP WITH THE OUTPORT COMMAND AND IT'S REQUIRED PARAMETERS.
IF YOU CAN HELP ME..... I WOULD GREATLY APPRECIATE IT!!!!  PLEASE READ ON:


I saw that you had mentioned to a guy that he should use 'output' as a way
to output to the serial port.  Well I am interested in outputing bytes to
specific pins on the parallel.  I was told to use the 'output' command
in such a fashion:

if I have 8 motors, and 1 is on, 0 off, and I want only motor 1 on I should
send the outport command the hex representation of 0000 0001 (#1 on) and the
hex value for that would be 1h.  Now no one was able to tell me exactly how
to send the parellel the command. I assumed (until I found out it didn't work)
that I should send it like:     outport(378h,1h);
                              		^    ^Hex value sent to port
     					Hex value for LPT1:
Now when I try to compile such a setup, it says ") missing in statement" or
something similar to that.  So I looked at some other things, and I decided 
that C handles Hex differently... like in that 0x00 format.  Is this correct?
What is this??  Well anyways, I tryed that: outport(378,0x01) and out(0x378,01)
and outport(378,01) and outport(0x378,0x01).  I didn't get the error any more,
but it didn't work either.  Do you know exactly what outport requires as passed
parameters?  I cant find anything that tells EXACTLY what it needs... so my 
best way to find out is by talking to other people who have used the command.

BTW I am 14 years old and am designing a small robotics project, so that is
why I need to know this.  The first steps are finding out how to output to
the ports.  If you have any other ideas/suggestions it is greatly appreciated..

Thanks....

-----------------------------------------------------------------------------
 Brendan O'Mara					Owner, Stealth Technologies,
 Email: omarab@jacobs.ucs.orst.edu		specializing in:
 Alias: Scorpion					
 Phone: (503)745-7549				Programming
						Computer Lessons
 Sysop of the Stealth BBS:			Computer Setup Assistance
 (503)745-7549, 9pm-7am weekdays,			
 24 hours most weekends.			Call for details!
------------------------------------------------------------------------------
-- 
-----------------------------------------------------------------------------
 Brendan O'Mara					Owner, Stealth Technologies,
 Email: omarab@jacobs.ucs.orst.edu		specializing in:
 Alias: Scorpion					
Newsgroups: comp.lang.c