[comp.sys.mac.programmer] Math in Think C 4.0

c60b-4av@web-4f.berkeley.edu (Gary Arnold) (01/14/91)

This may seem like a dumb question to some of you, but I'm a novice Think C
programmer (I posted "Could some kind soul help a new C programmer?"
...Thanks to all who replied).  What I want to know is this:  What are the
sine, cosine, tangent, etc. commands in Think C w/o using the math.h library?
I was told that the ANSI library slows it down (it does!), and was wondering
how to do trig functions without it.
I have IM I and II, but IM II only says that the Mac can perform these
functions, but not how to do them.  Then it mumbles something about if your
programming environment doesn't support them, then you better buy the Apple
Numerics Manual.  So, does anyone have an easy answer?
Thanks in advance!

P.S. If you can, please post the answers...this account should die any day
now...

Gary Arnold
c60b-4av@web.berkeley.edu

hairston@henry.ece.cmu.edu (David Hairston) (01/14/91)

[c60b-4av@web-4f.berkeley.edu (Gary Arnold) writes:]
[] ... What I want to know is this:  What are the
[] sine, cosine, tangent, etc. commands in Think C w/o using the math.h
[] library?

read the math.h file (and related header files).  duplicate the
declarations needed to implement sin and cos, etc. in your program
and you can avoid having to load the library.  if you have a FPU
and know that your code will only run on machines with a FPU you
can enable that option (losing some precision).  its been awhile
since i tried this but i don't think i left anything out.

(i hope you're not a novice novice ... ;)

  -dave-  
hairston@henry.ece.cmu.edu

pj@pnet51.orb.mn.org (Paul Jacoby) (01/16/91)

On the lines of <math.h>, I was gazing at my headers file just today (someone
else installed the software on this machine) and noticed that there was only
<math.h>. In the Sources folder, there is 'math881.c'.  How would one compile
'math881.c' for use, or is this already in the ANSI-881 library?

Question two on the same lines: how come the following code never is true?

#define MIN_SIZE 3

foo(double bar)
double bar;
{
   /* let's say bar = 3.666.... */
   if (bar > MIN_SIZE)
    {
      printf("Huzzah\n")
   }
}
.-----------------------------------------------------------------------------.
| UUCP: {crash tcnet}!orbit!pnet51!pj            | RTFD = Read The Silly Doc! |
| INET: pj@pnet51.orb.mn.org                     |                            |
`-----------------------------------------------------------------------------'