HDTenEightyP/NetNews huggingface dataset:
From: adams@pdv2.fmr.maschinenbau.th-darmstadt.de (Adams)
Newsgroups: comp.lang.c
Subject: Re: speed?  double vs. float.  math.h??
Date: 12 Jan 93 22:19:07
Organization: TH-Darmstadt
Distribution: world
NNTP-Posting-Host: pdv2.fmr.maschinenbau.th-darmstadt.de
In-reply-to: c60b-3hu@web-3c.berkeley.edu's message of 26 Dec 1992 09:17:53 GMT

In article <1hh801INNab1@agate.berkeley.edu> c60b-3hu@web-3c.berkeley.edu (Paul Hsu) writes:

>	I'm currently writing a C program where it needs to do lots and lots of
>   trig calculations.  But I would like the program to run really really fast.

Perhaps, find a better algorithm. For some problems requiring lots
of trigonometric calculation better algorithms are known
(FFT -> DFFT)

>   So I'm concerned about the speed at which the calculations are carried out.
>   Trying to make the program run fast, I would like to have only float 
>   variables, instead of doubles, in my program.  But in the standard math 
>   library, all the functions take in arguments and return values in the type 
>   double.  So, what should I do?  First of all, should I even be concerned 
>   about the speed difference between doing calculations in float and doing the
>   calculations in doubles?  If yes, how should I go about in making the math 
>   functions to accept and return floats?  Casting them won't help....  it'll 
>   only take more time in the type conversion.  Any suggestion?

As for most hardware (or micro code) implementations of floating point,
double or extended double are standard, calculations done
in float require additional [!] cycles to convert values to double
and results back to float ;-<.

I would be concerned about function call overhead. Therefore I would
prefer a compiler able to generate inline code accessing FP-hardware
in a direct manner insteadt via library call.
(GCC does this by special include files like math-68881.h, 
SUN's cc on SUN3 do it without support by special include files.)

best adams

Newsgroups: comp.lang.c
From: kimball@stsci.edu (Timothy Kimball)
Subject: Re: Any hope for me..?
Organization: Space Telescope Science Institute
X-Newsreader: TIN [version 1.1 PL6]
Date: Mon, 4 Jan 1993 15:07:57 GMT

Dave Eisen (dkeisen@leland.Stanford.EDU) wrote:
: In article <1993Jan2.215528.1@npe.isnet.inmos.co.uk> adcrumpler@npe.isnet.inmos.co.uk writes:
: 
: >
: >What I'd like to know is:-  What range of academic qualifications
: >do the various contributors possess ?  And can I, who didnt really
: >make the most of his schooldays, hope to attain similar levels
: >of knowledge and competence as you all possess ?
: 
: Academic qualifications are not real important for programming. I
: have all kinds of academic qualifications, none of which are in
: CS or engineering. I learned all I know about C, UNIX, programming,
: and the rest of CS by reading books, having a job which forced me 
: to learn a little bit, reading the net, and sitting in on a few courses.

I'll second this.  All I ever learned in a formal classroom was Fortran.
C, Unix, etc. are, IMHO, best learned at the keyboard (maybe with K&R2
at your elbow).  I don't think your (adcrumpler's) future depends as much
on how you spent your school days as how you'll spend the next couple of
years.

tdk

BTW: My backgound is physics and astronomy.

BTWBTW: adcrumpler, if you don't know:
"K&R2" means _The C Programming Language_, 2nd Edition, 
 by Kernighan and Ritchie.

Newsgroups: comp.lang.c
From: brad@spartan.ac.BrockU.CA (Brad Saxton)
Subject: A question about memory
Organization: Brock University, St. Catharines Ontario
X-Newsreader: Tin 1.1 PL4
Date: Mon, 4 Jan 1993 21:08:04 GMT

A quick question to help me in my quest to become a fair C programmer.

Lets say you call an operating system function (say getpwuid) that 
returns a pointer to a structure. At some point, the information 
returned will no longer be needed, so we would like to return the memory 
to the available pool. My question is HOW?

Please don't say use 'free' because that causes CORE dumps. If there 
is no way to return the memory, does it stay allocated until main 
is exitted?

Please respond via e-mail and I will post the solution unless of course 
it makes me look like an idiot for asking the question. ;-)

Thank you in advance for your time

Brad Saxton
brad@spartan.ac.BrockU.CA
From: ayoung@vax.oxford.ac.uk
Newsgroups: comp.lang.c
Subject: Re: Dynamic loading of functions
Date: 3 Jan 93 23:09:43 GMT
Organization: Oxford University VAX 6620

In article <mjjrcjn@lynx.unm.edu>, peter@deepthought.unm.edu (Peter Blemel) writes:
> Is there a portable way to load and execute a function in an object file from
> a running program? I'm writing a program that does some math stuff and I'd
> like to allow users to write their own functions to suppliment the supplied
> functions.

 I was doing a similar thing a couple of years ago, and (sadly) failed to
find a direct way to do it.  The `solution' I used was to incorporate an
interpretor into my program (based loosely on C syntax with extensions to
allow the user to call routines already defined with the main program).
This allowed the main program to input source code from a file defined by
the user - this code was then partially compiled (ie. tokenized with function
and variable names replaced by pointers, and stored as an execution tree).
Then this internal format was executed by the main program whenever it was
called.

 The disadvantage of this approach was (obviously) speed: the user-defined
interpreted subroutines ran about 20-30% of the speed of equivalent compiled
code.  On the plus side, the code was fully portable between machines since
the language it interpreted was my own specification programmed in C (and
since I'd never written a compiler I quite enjoyed doing it!).  I suspect
(but without evidence) that this is the method use by packages such as
Mathematica?

 Meanwhile, if anyone has a direct way to link into object files without
altering the EXE code please could they post it!

-------------------------------------------------------------------------------
     ___
    /   \   /                 |    /      Alan Young @ uk.ac.ox.vax
   /____/  /  ___    __       |___/
  /    /  /  /   |  /  |         /           "The bigger they are,
 /     \_/\__\__/|_/  /_________/               the harder they fall on you."
From: gegu@zurich.spectrospin.ch (Gerry Gucher)
Newsgroups: comp.lang.c
Subject: Re: Unsolveable bug
Summary: malloc problem is probably a programmer problem
Date: 6 Jan 93 16:16:19 GMT
Organization: Spectrospin AG, Fallanden Switzerland

In article <1hq27eINNjv@uwm.edu>, markh@csd4.csd.uwm.edu (Mark) writes:
> 
>    I've run into an unsolveable bug.  The bug comes from no visible error, it
> disappears when searched for under a debugger, and it's likewise non-existent
> when the same program is run under other platforms and compilers.  And it
> doesn't involve anything having to do with timing of any sort.
> 
>    It appears on the DOS port of the program and causes the machine to crash
> immediately after a call to malloc().  The malloc call is the ANSI-compatible
> call, declared with the <stdlib.h> header.  The particular usage leading to
> the crash is (as determined by traces): malloc(16), malloc(16), malloc(20), ...
> with no intervening free() calls.  All calls to malloc() return valid pointers.
> Checking the memory usage reveals no corruption or access out of bounds.

You probably haven't checked carefully enough.

> 
>    The compiler creating the problem has had reliable error-free performance
> with other similar programs.

Have you also checked the programmer for reliable error-free performance with
other similar programs ?

It would help much if you could could state the kind of system and OS you are
using. Code might help too, but its unlikely because the source of the error
is probably far away from the place where the crash occurred.

If you are working on a Sun workstation do yourself a favor and
use "malloc_debug" and if this not sufficient get a copy of the "Purify" 
package from Pure Software (CA +(408) 720-1600). Price is approx. ~1900
UK pounds. I don't know the price in US$. 

I have no relationship to "Pure" except being a satisfied customer. (This is
quite tough to achieve).

Gerry


+------------------------------------------------------------------+
| Gerry Gucher                             gegu@spectrospin.ch	   |
| Spectrospin AG,  Industriestr 26,  8117  Faellanden Switzerland  | 
+------------------------------------------------------------------+
| A program that  returns the  wrong | There is nothing wrong with |
| result twice as fast is infinitely | making  mistakes,  but make |
| slower.               - H. Spencer | new ones.           - D.Sim |	
+------------------------------------------------------------------+
From: jcu@dec5.ulb.ac.be (Jean-Christophe Ury)
Newsgroups: comp.lang.c
Subject: test mono / color ?
Date: 5 Jan 93 09:20:25 GMT
Distribution: world
Organization: Free University Brussels  - Belgium -  Department of Molecular Biology


There is no stupids questions (I hope) there is just stupids answers.  

I use ULTRIX v4.3 on a DEC station.


I wish to test within a Cprg the type of monitor I use...color or monochrome.
How to do this ?


Thanx everybody.
Happy new year.


email: jcu@is1.bfu.vub.ac.be
Newsgroups: comp.lang.c
From: brad@spartan.ac.BrockU.CA (Brad Saxton)
Subject: A question about memory - EUREKA !
Organization: Brock University, St. Catharines Ontario
X-Newsreader: Tin 1.1 PL4
Date: Tue, 5 Jan 1993 13:57:41 GMT

Thanks to everyone (except for one rude bugger) for their quick and useful
responses to my question.

To review, I was wondering how memory was allocated by library functions that
return pointers. I like to return memory to the free pool as quickly as I can.

The answer is (in hindsight) simple. Library functions of this type declare
a static variable and return a pointer to this area as their result. Very simple
and clean but it has the unfortunate effect of not being able to call these
types of functions multiple times without first copying the values out from the
static variable before calling it again. 

For example, a typical library function like getpwnam might have been declared
as follows:

	struct passwd *getpwnam (const char *name) {
        static struct passwd localvar; /* this area is reused by all calls */
		.
		.
		guts of function
		.
		.
	return &localvar;
	}

Again, thanks to all the polite and kind souls who replied to my plee.
                         ======

Brad Saxton
From: ag129@cus.cam.ac.uk (Alasdair Grant)
Newsgroups: comp.lang.c
Subject: Re: Questions about token merging and trigraphs
Date: 5 Jan 93 13:01:33 GMT
Organization: U of Cambridge, England

In article <1992Dec21.172815.18921@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
>In spite of the (apparent) fact that *nobody* uses them?  I have yet to
>see even *one* posting, even from .nl or .be or anywhere else that one
>might expect to see trigraphs in use, that actually supports them.  No,
>I still stand by my position that trigraphs are a stupid and
>unsuccessful attempt to solve a nevertheless very real problem.

I use them all the time.  As some people have already pointed out,
the problem is not so much local (although it is true that my keyboard
lacks square brackets and circumflex) but global.  For some character
sets there are no universally accepted rules for translating into ASCII;
this means that different compilers can behave in different ways.
For example, one compiler on my machine reads the character X'5F' as
the exclusive-OR operator; another reads it as the ones-complement
operator.  (It is the character known as "NOT sign", which usually
maps on to ASCII circumflex, but since we have a local code for that,
we map NOT on to ASCII tilde.)

Another one is vertical bar; many character (including ISO Latin 1) have
both solid and broken varieties.  Imagine someone who had followed K&R2
and used broken bar, only to discover that their compiler writer had
followed the C standard (ANSI printing, at least) and used the solid bar!
Yet the ANSI standard is sufficiently informal that both compilers are
standard-conforming.  (Unless you interpret the standard to say that all
C source code must appear in 10-point Courier bold, as it does in the
standard.  Seriously, I wouldn't want to deny Braille users a conforming
C compiler.)

I sympathise with people who are worried about lexer overheads, though
any compiler writer is at liberty to implement a #pragma notrigraphs.
It's too late for a #pragma trigraphs since there are enough compilers
around who will accept trigraphs anyway. The point about making trigraphs
part of the standard is so that I can not only ship my source code to
other similar systems, I can also run it under gcc on Unix and Microsoft
C on my PC as well.

All examples of code breakage I have seen are bad style to start with;
e.g. I'd write der Mouse's example of "?+??=??/" etc. as
  "?"      /* 0: reserved */
  "+"      /* 1: */
etc. using ANSI string concatenation. I'd put large pieces of text into
a help file or message repository. I'd read "tags" from a config. file.
(Not that I have much confidence in "tags" anyway - the program that
somebody had that used the string "??(" as a marker in files might have
problems when faced with ANSI C source code, or indeed with all the old
K&R source code that we are assured also contains "??(".)

So hooray for trigraphs.  And hooray for vendors like Microsoft who
support them without making a fuss or putting snide comments in their
documentation.
Newsgroups: comp.lang.c
From: wje@siia.mv.com (Bill Ezell)
Subject: Re: Conversion of BASIC code to "C"
Organization: Software Innovations, Inc.
Date: Mon, 11 Jan 93 12:31:29 GMT

>In article <1993Jan8.183821.20711@adobe.com>, (Scott Sivi) writes:
>> Does there exist a method or application by which BASIC files can be
>> converted 
>> to "C".
>You probably couldn't even do it by hand unless the BASIC program was 
>completely flowed and never used a GOTO! The way BASIC programmers spaghetti-
>code programs, I doubt it's possible. (I'm assuming you won't use goto in C.
>I wouldn't.)

An absurd statement, of course. There are several commercially available
Basic-to-C translators. Some are better than others. Given the enormous
number of Basic variants out there, if you're not using a common and
popular Basic, you might have trouble finding one.
We have one for MS PDS Basic to C.

As for never using a goto, there are quite good and practical reasons
for using them. This isn't to say that they should be used with any
regularity, but they can sometimes result in much more readable code.
A prime example is getting to a common error point in a routine that
has deep nesting of conditionals or other control constructs. Also,
many machine-generated C programs use gotos. Ever looked at a yacc parser?

wje@siia.mv.com
-- 
------------------------------
| Bill Ezell                 |
| Software Innovations, Inc. |
| wje@siia.mv.com            |
Newsgroups: comp.lang.c,comp.lang.c++
From: rfries@sceng.ub.com (Robert Fries)
Subject: Re: Dynamic Mem Help
Organization: Ungermann Bass
Date: Fri, 8 Jan 1993 17:05:11 GMT

In article <93007.230524U10139@uicvm.uic.edu> T J Furstenau <U10139@uicvm.uic.edu> writes:
... stuff deleted
>    char *str = NULL;

>    /* allocate memory for string */
>    str = calloc(10, sizeof(char));
... more stuff deleted
>I get the following error message:

>Error D:\BC\BIN\WORK\NONAME00.CPP 10: Cannot assign 'void near*' to
>'char near*' in function main().

>Any ideas in what I or my system are doing wrong?  Are my compiler options
>set wrong?  Any answers, here or mailed, would be greatly appreciated.

C++ and ANSI C do fairly strict type-checking, and since
malloc() and calloc() are used to allocate memory for
different types of objects, they are declared to return
(void *), which is sort of a generic pointer.

You'll have to use an explicit cast of this value to 
assign it to a variable of type 'char *', e.g.:

	str = (char *)calloc(10, sizeof(char));
	       ^^^^^^	
Robert



//////////////////////////////////////////////////////////////////////////
Robert Fries
Ungermann-Bass Inc.

DISCLAIMER:
    Opinions contained herein are my own, and are not necessarily those
    of Ungermann-Bass.
//////////////////////////////////////////////////////////////////////////
Newsgroups: comp.lang.c
From: eager@eagercon.com (Michael J. Eager)
Subject: Re: Problem with string processing.
Reply-To: eager@eagercon.com
Organization: Eager Consulting
Date: Mon, 11 Jan 1993 06:06:15 GMT

In article 1idn10INNpvg@calamari.hi.com, rogers@calamari.hi.com (Andrew Rogers) writes:
>In article <Ts3TwB1w165w@wozzle.linet.org> alane@wozzle.linet.org (J. Alan Eldridge) writes:
>>>         char tmp[2] = {0};
>>>  
>>>         *tmp = ch;
>>>         strcat(str, tmp);
>>
>>tmp[0] has a 0 in it but tmp[1] is undefined. You are not creating
>>a nul-terminated string here.
>
>tmp[1] most certainly does have a 0 in it; if the initialization list for
>an array contains fewer elements than the array itself, then the remaining
>array elements are initialized to 0.  Check the ANSI spec, or the relevant
>section in K&R.

Well, the relevent section is 3.5.7, which says, in part "If an object that 
has automatic storage duration is not initialized explicitly, its value is
indeterminate."  Lacking a 'static' declaration and being within a function
means that tmp has automatic storage.  Only the first element is initialized
to zero, tmp[1] is undefined.

For static storage objects, all uninitialize elements get binary zero values.


---
Michael J. Eager		Michael.Eager@eagercon.com
Eager Consulting		(415) 325-8077 
1960 Park Boulevard, Palo Alto, CA 94306-1141

Newsgroups: comp.lang.c
From: bryan@sphinx.phys.Virginia.EDU (bryan wright)
Subject: Re: Curses question: printf after initscr
Organization: University of Virginia
Date: Mon, 11 Jan 1993 15:17:20 GMT

Hi again,
	Thanks to all those who set me straight.  I needed to explicitly
fflush stdout before the 'gets' call.  I guess I'd just assumed that 
'gets' automagically flushed stdout.

\begin{ EmilyLittella }  Never mind . . . \end{ EmilyLittella }


				Bryan
--
===============================================================================
Bryan Wright                |"If you take cranberries and stew them like 
Physics Department          | applesauce, they taste much more like prunes 
University of Virginia      | than rhubarb does."  --  Groucho
From: jwh@cs.bham.ac.uk (James Hawtin)
Newsgroups: comp.lang.c
Subject: Floating point libraries
Date: 5 Jan 93 14:37:07 GMT
Reply-To: jwh@cs.bham.ac.uk
Organization: School of Computer Science, The University of Birmingham, UK

Does anyone know of a floating point library for the Sun that allows extremely large
numbers of significate digits (about 1024 bits)?

		Thanks

			James.
From: apn@Apple.COM (Alex Novickis)
Newsgroups: comp.lang.c
Subject: Re: C code Layout
Date: 7 Jan 93 19:09:52 GMT
Organization: Apple Computer Inc, Cupertino, CA

In article <MITCH.92Dec24105749@pollux.clsi> mitch@clsi.COM (Mitchell N. Perilstein) writes:
>> P.S I've got some macros for vi that solve mazes. Try that in poo. Sorry,
>> EMACS.
>
>I've got some lisp for emacs which emulates vi.  Does vi emulate emacs?
>
That's exactly it!!!!!! Emacs users still have a need for vi ( I guess to
do real editing) and vi users have no need for emacs ( for whatever it
is used for )



-- 
Alex P. Novickis, Real Time systems demi-guru.  (W)   408-862-4541
ALINK:alex.n                                    (H)   415-691-0657
UUCP:{amdahl,claris,pyramid,sun,decwrl,well,ubvax,ames}!apn@apple.com,apn@nonvon
"I think... I think it's in my basement. Let me go upstairs and check"-Escher.
Newsgroups: comp.lang.c
From: hollasch@kpc.com (Steve Hollasch)
Subject: Re: JOYSICK HANDLER HELP.... PLEASE EMAIL RESPONCE!!  Thanks...
Followup-To:  alt.clueless
Summary: Sigh
Keywords: joystick C c++ help IBM
Organization: Kubota Pacific Computer, Inc.
Distribution: usa
Date: Tue, 5 Jan 1993 08:54:42 GMT

omarab@atlantis.CS.ORST.EDU (Scorpion) writes:
| I need some help with a joystick handler.  If you can help me, I would
| appreciate it!!!
| 
| I originally wrote this program to control one joystick.  It made an int86
| call (see code below) to set the registers to the X and Y coordinates for 
| the joystick. I could then display the coordinates on screen.  Now I decided
| to rewrite the program to display the coordinates for 2 joysticks.  According
| to the book I was reading, the registers were assigned as follows:

    [blah blah blah]

| If you can help me, please E-Mail your responce... it is better for me that
| way because I have to log into a different machine that normal to access
| news..

    Gee Mr. Scorpion sir, can I just write it on paper and deliver it to
you in person?  That way I can polish your shoes while you read it, and you
won't have to go through all that effort logging into another machine.

    Besides the fact that you are using the C language to do this stuff,
what does this have to do with C syntax, portability, or other language
issues?  You'd be better off posting this to a group that deals with your
specific hardware.

______________________________________________________________________________
Steve Hollasch                                   Kubota Pacific Computer, Inc.
hollasch@kpc.com                                 Santa Clara, California
From: castori@litsun29.epfl.ch (Pierre Castori)
Newsgroups: comp.lang.c
Subject: Ada2C
Date: 5 Jan 93 15:08:50 GMT
Organization: Ecole Polytechnique Federale de Lausanne


-- 
Hi everybody,

Has anybody out there already heard about an Ada to C translator ?
I don't even know if this exists but if you know about such a translator could
you please let me know.


Thanx,

==========================================================================
Pierre Castori
Dept. of Computer Science
Swiss Federal Institute of Technology
EPFL - IN ECUBLENS
1015 LAUSANNE (Switzerland)                  Email: castori@litsun.epfl.ch
==========================================================================
Newsgroups: comp.lang.c
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Moving from Pascal to C, Help please!!!!!!
Organization: Sequoia Peripherals, Inc.
Date: Tue, 5 Jan 93 16:25:04 GMT

In article <C04E63.863@newcastle.ac.uk> Raj.Subramani@newcastle.ac.uk (D. Subramani) writes:
>
>I would recommend that you have a look at "Numerical Recipies in C"
>'cause there they explain how arrays of 2-D are pointers to a pointer
>and so on which no one else does. Also they have a few routines that
>allocate memory as per your requirement, ie. [6...26] etc. but be 
>warned, when you do that you will not be able to exploit the advantages
>of pointer arethmatic fully (it will be too confusing).

I've never read this book, but I sincerely hope that they do
not explain that 2D arrays are pointers to pointers because
they most certainly are not. This distinction is not fully
understood by a large number of new C programmers and a question
about it appears here every week or two. I would hate to think
that popular books like "Numerical Recipes in C" are contributing
to this misunderstanding.

I can tolerate what they do with arrays ranging from 6 to 26 because
while it is not legal C, it does work on every system I've ever
heard about. Still, it would be nice if they had gotten this
right too.

I've heard very good things about this book, at least about the
numerical methods it discusses. Still, if I had a need for
numerical methods in my programs, I would buy the original
Numerical Recipes (written in, I assume, FORTRAN) and do the
conversion myself. I don't even know FORTRAN, but I would
feel more comfortable trying to decipher the FORTRAN myself
and converting it to C than I would trusting the author's
knowledge of C.



-- 
Dave Eisen                               Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
       There's something in my library to offend everybody. 
          --- Washington Coalition Against Censorship
Newsgroups: comp.lang.c