Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Something Seemingly Simple.

1 view
Skip to first unread message

Bloody Viking

unread,
Feb 23, 2001, 10:37:55 PM2/23/01
to

I just tried a simple trig thing on my Linux box but the gcc compiler gave me
some error, despite having math.h added as the libraries. More bizarre, my
UNIX ISP had exactly the same problem with the same seemingly simple proggie.

I'm fully sure it's a stupid=shit problem on my part. Here's the code:

---begin---
@include <stdio.h>
@include <math.h>
float angle, hypoteneuse, output;
main()
{
printf("input the angle");
scanf("%f", &angle);
printf("input the hypoteneuse");
scanf("%f", &hypoteneuse);
output = cos(angle);
printf("%f\n", output);
}
---end code---

When I try to compile it, the gcc compiler gives out wierd errors, not, say
syntax errors or the like. What's wrong? Is it my not making the cos thing
right or what? Trig has some significant uses is real life, not just for a
case of a school going ape-shit over math. With trig use, it is possible with
needed equipment to reverse engineer glasses prescriptions, ballistics, etc.

For clues, here are the wierd errors:
---begin---
/tmp/cca262191.o: In function 'main':
/tmp/cca252191.o(.text+0x51): undefined reference to 'cos'
---end error---

I'm runnin' Slackware 3.0 with the 2.0.0 kernel, which is awful ancient by
now. I have a Slackware 7.2 album ready to use, so if I have to upgeade I
can. I would like to see a solution in this case so I can carry it onto the
upgrade. Trig has become "strategic" and I want my computer to do it.

I'm fully sure that it is misconfigured as of now and my discovery awaited
my need for trig use.

--
FOOD FOR THOUGHT: 100 calories are used up in the course of a mile run.
The USDA guidelines for dietary fibre is equal to one ounce of sawdust.
The liver makes the vast majority of the cholesterol in your bloodstream.

Richard Heathfield

unread,
Feb 23, 2001, 10:43:36 PM2/23/01
to
Bloody Viking wrote:
>
> I just tried a simple trig thing on my Linux box but the gcc compiler gave me
> some error, despite having math.h added as the libraries. More bizarre, my
> UNIX ISP had exactly the same problem with the same seemingly simple proggie.

Your question is an FAQ - there's a good answer to be found if you look
for it. See my sig for the URL.

--
Richard Heathfield
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton

mlw

unread,
Feb 23, 2001, 10:58:24 PM2/23/01
to
First of all, includes need '#' symbols not '@'.

Then type 'cc -o prog prog.c -lm'

--
The majority of the stupid is invincible and guaranteed for all time.
The terror of their tyranny, however, is alleviated by their lack of
consistency.
-- Albert Einstein
------------------------
http://www.mohawksoft.com

Dan Pop

unread,
Feb 23, 2001, 10:57:27 PM2/23/01
to
In <977aaj$hfp$1...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:


>I just tried a simple trig thing on my Linux box but the gcc compiler gave me
>some error, despite having math.h added as the libraries. More bizarre, my
>UNIX ISP had exactly the same problem with the same seemingly simple proggie.
>
>I'm fully sure it's a stupid=shit problem on my part. Here's the code:

It is, indeed: you have posted to comp.lang.c without reading its FAQ
first!

Dan
--
Dan Pop
CERN, IT Division
Email: Dan...@cern.ch
Mail: CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland

Martin Ambuhl

unread,
Feb 24, 2001, 1:32:29 AM2/24/01
to
Bloody Viking wrote:
>
> I just tried a simple trig thing on my Linux box but the gcc compiler gave me
> some error, despite having math.h added as the libraries. More bizarre, my
> UNIX ISP had exactly the same problem with the same seemingly simple proggie.
...

> For clues, here are the wierd errors:
> ---begin---
> /tmp/cca262191.o: In function 'main':
> /tmp/cca252191.o(.text+0x51): undefined reference to 'cos'
> ---end error---

This is a FAQ. As a good usenet citizen, you looked already, I know.
However, you missed it. Try again.

Mark Duell

unread,
Feb 24, 2001, 2:11:32 AM2/24/01
to
"Richard Heathfield" <bin...@eton.powernet.co.uk> wrote in message
news:3A972DE8...@eton.powernet.co.uk...

> Bloody Viking wrote:
> >
> > I just tried a simple trig thing on my Linux box but the gcc compiler
gave me
> > some error, despite having math.h added as the libraries. More bizarre,
my
> > UNIX ISP had exactly the same problem with the same seemingly simple
proggie.
>
> Your question is an FAQ - there's a good answer to be found if you look
> for it. See my sig for the URL.
>
> --
> Richard Heathfield
> "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
> C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

This link returns a 404 (and a custom one at that!)

> K&R answers, C books, etc: http://users.powernet.co.uk/eton

This isnt what he wants/needs.

Cheers,
Mark Duell
:)


Richard Heathfield

unread,
Feb 24, 2001, 3:43:22 AM2/24/01
to
Mark Duell wrote:
>
> "Richard Heathfield" <bin...@eton.powernet.co.uk> wrote in message
> news:3A972DE8...@eton.powernet.co.uk...
> > Bloody Viking wrote:
> > >
> > > I just tried a simple trig thing on my Linux box but the gcc compiler
> gave me
> > > some error, despite having math.h added as the libraries. More bizarre,
> my
> > > UNIX ISP had exactly the same problem with the same seemingly simple
> proggie.
> >
> > Your question is an FAQ - there's a good answer to be found if you look
> > for it. See my sig for the URL.
> >

[and that sig says...]

> > C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
>
> This link returns a 404 (and a custom one at that!)

Interesting. I just tried it, and it worked fine. Reload and
Shift-Reload both work fine too.

Are you sure you didn't just catch it at a busy time?

--
Richard Heathfield
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

Mark McIntyre

unread,
Feb 24, 2001, 4:10:10 AM2/24/01
to
On Sat, 24 Feb 2001 07:11:32 GMT, "Mark Duell" <fleacircus.org@mduell>
wrote:

>"Richard Heathfield" <bin...@eton.powernet.co.uk> wrote in message
>news:3A972DE8...@eton.powernet.co.uk...
>> Bloody Viking wrote:
>> >
>> > I just tried a simple trig thing on my Linux box but the gcc compiler
>gave me
>> > some error, despite having math.h added as the libraries. More bizarre,
>my
>> > UNIX ISP had exactly the same problem with the same seemingly simple
>proggie.
>>
>> Your question is an FAQ - there's a good answer to be found if you look
>> for it. See my sig for the URL.
>>
>> --
>> Richard Heathfield
>> "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
>> C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
>
>This link returns a 404 (and a custom one at that!)

no it doesn't.

--
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>

Edward Rosten

unread,
Feb 24, 2001, 5:26:12 AM2/24/01
to
> For clues, here are the wierd errors:
> ---begin---
> /tmp/cca262191.o: In function 'main':
> /tmp/cca252191.o(.text+0x51): undefined reference to 'cos'
> ---end error---


Those are perfectly normal errors: you have no cos function. You need to
link against the maths library as well as #including the header.

gcc -lm ...


should do the trick.

-Ed

--
| u98ejr
| @
Share, and enjoy. | eng.ox
| .ac.uk

-hs-

unread,
Feb 24, 2001, 6:15:58 AM2/24/01
to
Bloody Viking a écrit dans le message <977aaj$hfp$1...@gail.ripco.com>...

>
>I just tried a simple trig thing on my Linux box but the gcc compiler gave
me
>some error, despite having math.h added as the libraries. More bizarre, my
>UNIX ISP had exactly the same problem with the same seemingly simple
proggie.
>
>I'm fully sure it's a stupid=shit problem on my part. Here's the code:
>
>---begin---
>@include <stdio.h>
>@include <math.h>

Nice one. What about # instead?

>float angle, hypoteneuse, output;

Why file scope?

>main()

int main()

>{
>printf("input the angle");
>scanf("%f", &angle);

type "twenty" and see what happens

>printf("input the hypoteneuse");
>scanf("%f", &hypoteneuse);
>output = cos(angle);
>printf("%f\n", output);


return 0;
>}
>---end code---


Works fine (probaly the -lm problem. It's a FAOTQ, at last on CLC)


What about that:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>

static double get_double(char const *const sprompt)
/* could be enhanced by a status return:
* static int get_double(char const *const sprompt, double *presult)
*/
{
#define FUNCTION "get_double"
double result;
char s[BUFSIZ];

printf ("%s: ", sprompt);
fflush (stdout);
fgets (s, sizeof s, stdin);

{
char *p;
result = strtod (s, &p);

if (p == s)
{
fprintf(stderr, FUNCTION": Input error\n");
}

if (errno)
{
perror(FUNCTION);
}
}

return result;
#undef FUNCTION
}

int main (void)
{
double const angle = get_double ("input the angle");
double const hypoteneuse = get_double ("input the hypoteneuse");
double output;

output = cos (angle);
printf ("%f\n", output);

return 0;
}

--
-hs- Tabs out, spaces in.
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
FAQ de FCLC : http://www.isty-info.uvsq.fr/~rumeau/fclc

Aaron Kulkis

unread,
Feb 24, 2001, 6:33:18 AM2/24/01
to

Bloody Viking wrote:
>
> I just tried a simple trig thing on my Linux box but the gcc compiler gave me
> some error, despite having math.h added as the libraries. More bizarre, my
> UNIX ISP had exactly the same problem with the same seemingly simple proggie.
>
> I'm fully sure it's a stupid=shit problem on my part. Here's the code:
>
> ---begin---
> @include <stdio.h>
> @include <math.h>


/* try these instead */

#include <stdio.h>
#include <math.h>

--
Aaron R. Kulkis
Unix Systems Engineer
DNRC Minister of all I survey
ICQ # 3056642

L: "meow" is yet another anonymous coward who does nothing
but write stupid nonsense about his intellectual superiors.


K: Truth in advertising:
Left Wing Extremists Charles Schumer and Donna Shelala,
Black Seperatist Anti-Semite Louis Farrakan,
Special Interest Sierra Club,
Anarchist Members of the ACLU
Left Wing Corporate Extremist Ted Turner
The Drunken Woman Killer Ted Kennedy
Grass Roots Pro-Gun movement,


J: Other knee_jerk reactionaries: billh, david casey, redc1c4,
The retarded sisters: Raunchy (rauni) and Anencephielle (Enielle),
also known as old hags who've hit the wall....

I: Loren Petrich's 2-week stubborn refusal to respond to the
challenge to describe even one philosophical difference
between himself and the communists demonstrates that, in fact,
Loren Petrich is a COMMUNIST ***hole

H: "Having found not one single carbon monoxide leak on the entire
premises, it is my belief, and Willard concurs, that the reason
you folks feel listless and disoriented is simply because
you are lazy, stupid people"

G: Knackos...you're a retard.


F: Unit_4's "Kook hunt" reminds me of "Jimmy Baker's" harangues against
adultery while concurrently committing adultery with Tammy Hahn.

E: Jet is not worthy of the time to compose a response until
her behavior improves.

D: Jet Silverman now follows me from newgroup to newsgroup
...despite (C) above.

C: Jet Silverman claims to have killfiled me.

B: Jet Silverman plays the fool and spews out nonsense as a
method of sidetracking discussions which are headed in a
direction that she doesn't like.

A: The wise man is mocked by fools.

Ian Woods

unread,
Feb 24, 2001, 7:30:51 AM2/24/01
to
ma...@garthorn.demon.co.uk (Mark McIntyre) wrote in
<qiue9t0na6n07hnj7...@4ax.com>:

>On Sat, 24 Feb 2001 07:11:32 GMT, "Mark Duell" <fleacircus.org@mduell>
>wrote:
>
>>"Richard Heathfield" <bin...@eton.powernet.co.uk> wrote in message
>>news:3A972DE8...@eton.powernet.co.uk...

>>> Richard Heathfield
>>> "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
>>> C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
>>
>>This link returns a 404 (and a custom one at that!)
>
>no it doesn't.
>

That depends if the customisation happens to be a 404 page containing the
FAQ :D

Ian Woods

Bloody Viking

unread,
Feb 24, 2001, 7:41:40 AM2/24/01
to

Edward Rosten (lo...@my.sig) wrote:

: Those are perfectly normal errors: you have no cos function. You need to


: link against the maths library as well as #including the header.

: gcc -lm ...

The "0lm" trick sure did it. Just tested it on another virtual console.
Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?

-hs-

unread,
Feb 24, 2001, 8:08:40 AM2/24/01
to
Bloody Viking a écrit dans le message <978a64$r1q$1...@gail.ripco.com>...

[about cos() in math.h> ]

>Why isn't it in degrees as is the standard?

To avoid the question "Why isn't it in radians as is the standard?"

--

-hs-

unread,
Feb 24, 2001, 8:11:19 AM2/24/01
to
Aaron Kulkis a écrit dans le message <3A979BFE...@yahoo.com>...

Are you awared that the recommend maximum length for a .sig is 4 lines?

mlw

unread,
Feb 24, 2001, 9:01:08 AM2/24/01
to
-hs- wrote:
>
> Are you awared that the recommend maximum length for a .sig is 4 lines?

I assume you mean "aware," ;) and yes I am sure he is, however, if he is not
embarrassed by the content, I doubt the length is an issue.

cat < nonsense > cola

unread,
Feb 24, 2001, 9:11:09 AM2/24/01
to
You are only encouraging this obviously troubled individual. Just do what
most do when faced with perverse and irrational human behavior --Walk away
shaking your head and then banish this never-ending, self serving, patently
ignorant, olfactory offensive, bandwidth wasting written trash to the bit
bucket of Usenet. Please don't feed the mentally ill, unless it's a hockey
puck sized Prozac.

[patient K's hideous signature snipped]

-hs-

unread,
Feb 24, 2001, 9:16:07 AM2/24/01
to
mlw a écrit dans le message <3A97BEA4...@mohawksoft.com>...

>> Are you awared that the recommend maximum length for a .sig is 4 lines?
>I assume you mean "aware," ;)


Oops, I had a doubt...

gou...@email.com

unread,
Feb 24, 2001, 9:40:56 AM2/24/01
to
Bloody Viking wrote:
>
> Edward Rosten (lo...@my.sig) wrote:
>
> : Those are perfectly normal errors: you have no cos function. You need to
> : link against the maths library as well as #including the header.
>
> : gcc -lm ...
>
> The "0lm" trick sure did it. Just tested it on another virtual console.
> Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?
>

In short, radians are more often used in mathematics. Radians do have
some useful properties, particularly in keeping formulae simple (eg the
area of a segment of a circle is rT, where r is the radius and T is the
angle in radians subtended at the centre, if T is in degrees there is an
ugly constant involved)
--
http://www.guild.bham.ac.uk/chess-club

Edward Rosten

unread,
Feb 24, 2001, 10:23:55 AM2/24/01
to
In article <978a64$r1q$1...@gail.ripco.com>, "Bloody Viking"
<nos...@ripco.com> wrote:

> Edward Rosten (lo...@my.sig) wrote:
>
> : Those are perfectly normal errors: you have no cos function. You need
> to
> : link against the maths library as well as #including the header.
>
> : gcc -lm ...
>
> The "0lm" trick sure did it. Just tested it on another virtual console.
> Thanks! Fun easier quesation. Why isn't it in degrees as is the
> standard?

Radians are a much more natural measure (and are standard in a lot of
mathematics).

Here is an illustration of why they are more `natural'. If you were to
work out a McLaurin series for the purposes of, say calculating a cosine:

cos(x) = 1 - x^2 /2! + x^4/4! - x^6/6! + ...

it works correctly if you put in radians. Degrees are a unit invented
to make it easier to visualise.

Try defining a macro

#define dcos(X) cos(X*180/ M_PIl)

etc.

Chris Kern

unread,
Feb 24, 2001, 10:57:03 AM2/24/01
to
On 24 Feb 2001 12:41:40 GMT, nos...@ripco.com (Bloody Viking) posted
the following:

> Why isn't it in degrees as is the standard?

While degrees may be the standard for many people, mathemeticians
always (or nearly always) use radians.

-Chris

Joona I Palaste

unread,
Feb 24, 2001, 1:02:52 PM2/24/01
to
Bloody Viking <nos...@ripco.com> scribbled the following
on comp.lang.c:

> Edward Rosten (lo...@my.sig) wrote:

> : Those are perfectly normal errors: you have no cos function. You need to
> : link against the maths library as well as #including the header.

> : gcc -lm ...

> The "0lm" trick sure did it. Just tested it on another virtual console.
> Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?

Radians are more natural than degrees. Radians are based on a
fundamental measurement of all circles ever (ie. the constant pi), but
degrees are based on an entirely arbitrary human-specified number (360).

--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/

"Hasta la Vista, Abie!"
- Bart Simpson

Bloody Viking

unread,
Feb 24, 2001, 1:58:07 PM2/24/01
to

Edward Rosten (lo...@my.sig) wrote:

: Those are perfectly normal errors: you have no cos function. You need to


: link against the maths library as well as #including the header.

: gcc -lm ...

: should do the trick.

Someone else said the same thing, and sure enough it compiled up. Whether it's
degrees, radians, or grads, I'll have to figure it out and make a simple
conversion line. While I'm not the greatest programmer by any stretch of the
imagination, the odd error took me by surprise. That -lm switch will sure be
handy any time I decide to use trig in homebrew software.

When I compiled it up with the switch, I got an unexpected answer, as I used
45 for the angle, expecting degrees as the default, which would be .707... as
opposed to .850904. It looks like gcc uses radians. No matter, you slip in a
conversion line. (:

BTW, the posted code is officially GNU by my decree. :)

Bloody Viking

unread,
Feb 24, 2001, 2:10:37 PM2/24/01
to

-hs- (email....@server.invalid) wrote:

: To avoid the question "Why isn't it in radians as is the standard?"

So, it is in radians. Now that I know about the "-lm" switch for the compile,
I get to make a degree2radian conversion line to add to my code. Something
off-topic is that the TI-86 calculator out of the box defaults to radians.
(you set it to degrees)

Here's a chance to correct (and flame) me. Last time I checked, a full circle
is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
Time to add the conversion line to my little programme.

z00t

unread,
Feb 24, 2001, 1:33:59 PM2/24/01
to
-hs- wrote:
>
> What about that:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> #include <errno.h>
>
> static double get_double(char const *const sprompt)
> /* could be enhanced by a status return:
> * static int get_double(char const *const sprompt, double *presult)
> */
> {
> #define FUNCTION "get_double"
> double result;
> char s[BUFSIZ];
>
> printf ("%s: ", sprompt);
> fflush (stdout);
> fgets (s, sizeof s, stdin);
>
> {
> char *p;
> result = strtod (s, &p);
>
> if (p == s)
> {
> fprintf(stderr, FUNCTION": Input error\n");
> }
>
> if (errno)
> {
> perror(FUNCTION);
> }

You should zero errno before calling strtod(). BTW, why won't you put
this if statement just after calling strtod(), if you are trying to
catch a range error ?

> }
>
> return result;
> #undef FUNCTION
> }
>
> int main (void)
> {
> double const angle = get_double ("input the angle");

"input the angle (in radians)" could be a better prompt, IMHO.

> double const hypoteneuse = get_double ("input the hypoteneuse");
> double output;
>
> output = cos (angle);

You mean
output = cos(angle) * hypoteneuse;
I guess.

> printf ("%f\n", output);
>
> return 0;
> }


==================================
Posted via http://nodevice.com
Linux Programmer's Site

Bloody Viking

unread,
Feb 24, 2001, 2:25:04 PM2/24/01
to

gou...@email.com wrote:

: In short, radians are more often used in mathematics. Radians do have


: some useful properties, particularly in keeping formulae simple (eg the
: area of a segment of a circle is rT, where r is the radius and T is the
: angle in radians subtended at the centre, if T is in degrees there is an
: ugly constant involved)

So, THAT'S why radians are used by high-end mathematicians. The "ugly
constant" as you describe is the degrees to radians conversion constant, which
will be pi/360. That feature of radians would be useful for orbital mechanics
whereby at perigee the area of satellite motion and the planet's centre of
gravity over a second will equal that area at apogee, so you can determine
speed at the any point in an orbit if you know it at any one spot.

A fun factoid is that orbital mechanics was once called "celestial mechanics"
but is now too useful to us Earthlings as we launch all manner of small
functional "moons" to the point Earth has a ring 22,300 miles up.
(geosynchronous orbit) Newton never figured that his "celectial mechanics"
would be of _military_ significance. (spy sats)

Richard Heathfield

unread,
Feb 24, 2001, 2:37:19 PM2/24/01
to
Bloody Viking wrote:
>
> -hs- (email....@server.invalid) wrote:
>
> : To avoid the question "Why isn't it in radians as is the standard?"
>
> So, it is in radians. Now that I know about the "-lm" switch for the compile,
> I get to make a degree2radian conversion line to add to my code. Something
> off-topic is that the TI-86 calculator out of the box defaults to radians.
> (you set it to degrees)
>
> Here's a chance to correct (and flame) me. Last time I checked, a full circle
> is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
> Time to add the conversion line to my little programme.

Not just yet! :-)

There are 2 pi radians in a full circle, so the conversion is pi /
180.0:

double deg_to_rad(double degrees)
{
return degrees * 3.14159265358979323846 / 180.0;
}

--

Richard Heathfield
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

-hs-

unread,
Feb 24, 2001, 2:47:43 PM2/24/01
to
z00t a écrit dans le message <978uq...@news1.newsguy.com>...

>> {
>> char *p;
>> result = strtod (s, &p);
>>
>> if (p == s)
>> {
>> fprintf(stderr, FUNCTION": Input error\n");
>> }
>>
>> if (errno)
>> {
>> perror(FUNCTION);
>> }
>
>You should zero errno before calling strtod(). BTW, why won't you put


I am not sure. Do you meant that strdod() doesn't set errno to 0 if no
error?

>this if statement just after calling strtod(), if you are trying to
>catch a range error ?

Absolutely. My mistake.

>> double const angle = get_double ("input the angle");
>
>"input the angle (in radians)" could be a better prompt, IMHO.


Agreed.

>> output = cos (angle);
>
>You mean
>output = cos(angle) * hypoteneuse;
>I guess.


Probably. I'd just copied the OP's code. I am not that good at math. I'd
noticed that hypothenuse wasn't used.

z00t

unread,
Feb 24, 2001, 3:51:56 PM2/24/01
to
-hs- wrote:
> z00t a écrit dans le message <978uq...@news1.newsguy.com>...
> >> {
> >> char *p;
> >> result = strtod (s, &p);
> >>
> >> if (p == s)
> >> {
> >> fprintf(stderr, FUNCTION": Input error\n");
> >> }
> >>
> >> if (errno)
> >> {
> >> perror(FUNCTION);
> >> }
> >
> >You should zero errno before calling strtod(). BTW, why won't you put
>
>
> I am not sure. Do you meant that strdod() doesn't set errno to 0 if no
> error?
>
Yes.
[#3] The value of errno is zero at program startup, but is
never set to zero by any library function.

(from n869. but i believe it was the same in the previous Standart
and is still the same)

Mark Duell

unread,
Feb 24, 2001, 5:30:39 PM2/24/01
to
"Richard Heathfield" <bin...@eton.powernet.co.uk> wrote in message
news:3A97742A...@eton.powernet.co.uk...

> Mark Duell wrote:
> >
> > "Richard Heathfield" <bin...@eton.powernet.co.uk> wrote in message
> > news:3A972DE8...@eton.powernet.co.uk...
> > > Bloody Viking wrote:
> > > >
> > > > I just tried a simple trig thing on my Linux box but the gcc
compiler
> > gave me
> > > > some error, despite having math.h added as the libraries. More
bizarre,
> > my
> > > > UNIX ISP had exactly the same problem with the same seemingly simple
> > proggie.
> > >
> > > Your question is an FAQ - there's a good answer to be found if you
look
> > > for it. See my sig for the URL.
> > >
>
> [and that sig says...]
>
> > > C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
> >
> > This link returns a 404 (and a custom one at that!)
>
> Interesting. I just tried it, and it worked fine. Reload and
> Shift-Reload both work fine too.
>
> Are you sure you didn't just catch it at a busy time?
Ummm... well... yes... I guess I did, because I was given eskimo's 404 page.

Mark Duell


gou...@email.com

unread,
Feb 24, 2001, 5:51:14 PM2/24/01
to

*real* mathematicians don't really care
--
http://www.guild.bham.ac.uk/chess-club

Dan Pop

unread,
Feb 24, 2001, 7:40:17 PM2/24/01
to
In <97828t$dt6$1...@news.ox.ac.uk> "Edward Rosten" <lo...@my.sig> writes:

>> For clues, here are the wierd errors:
>> ---begin---
>> /tmp/cca262191.o: In function 'main':
>> /tmp/cca252191.o(.text+0x51): undefined reference to 'cos'
>> ---end error---
>
>
>Those are perfectly normal errors: you have no cos function. You need to
>link against the maths library as well as #including the header.
>
>gcc -lm ...
>
>should do the trick.

It may or may NOT do the trick. OTOH, gcc ... -lm *will* do the trick!

hpplus05:~/tmp 3> cat test.c
#include <math.h>

int main()
{
return sin(0);
}
hpplus05:~/tmp 4> gcc -lm test.c
/usr/ccs/bin/ld: Unsatisfied symbols:
sin (code)
collect2: ld returned 1 exit status
hpplus05:~/tmp 5> gcc test.c -lm
hpplus05:~/tmp 6> uname -a
HP-UX hpplus05 B.10.20 A 9000/782 2013972810 two-user license

Reading the c.l.c FAQ is *always* a good idea, even if you *know* that
you're right!

Dan
--
Dan Pop
CERN, IT Division
Email: Dan...@cern.ch
Mail: CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland

Dan Pop

unread,
Feb 24, 2001, 7:41:55 PM2/24/01
to
In <978a64$r1q$1...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:

>Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?

^^^^^^^^^^^^
What standard?!?

Aaron Kulkis

unread,
Feb 24, 2001, 8:06:41 PM2/24/01
to

Are you aware that this suggestion was formulated during the days
before fiber-optics, when MFM and RLL were not even invented yet,
and the ARPA-NET backbone had a 56k bandwidth and 20 megabyte disks
were considered huge...


> --
> -hs- Tabs out, spaces in.
> CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
> ISO-C Library: http://www.dinkum.com/htm_cl
> FAQ de FCLC : http://www.isty-info.uvsq.fr/~rumeau/fclc

--

Aaron Kulkis

unread,
Feb 24, 2001, 8:10:24 PM2/24/01
to

Bloody Viking wrote:
>
> -hs- (email....@server.invalid) wrote:
>
> : To avoid the question "Why isn't it in radians as is the standard?"
>
> So, it is in radians. Now that I know about the "-lm" switch for the compile,
> I get to make a degree2radian conversion line to add to my code. Something
> off-topic is that the TI-86 calculator out of the box defaults to radians.
> (you set it to degrees)
>
> Here's a chance to correct (and flame) me. Last time I checked, a full circle
> is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
> Time to add the conversion line to my little programme.
>

correct. Pi radians = one circle.


> --
> FOOD FOR THOUGHT: 100 calories are used up in the course of a mile run.
> The USDA guidelines for dietary fibre is equal to one ounce of sawdust.
> The liver makes the vast majority of the cholesterol in your bloodstream.

--

Aaron Kulkis

unread,
Feb 24, 2001, 8:09:30 PM2/24/01
to

Bloody Viking wrote:
>
> Edward Rosten (lo...@my.sig) wrote:
>
> : Those are perfectly normal errors: you have no cos function. You need to
> : link against the maths library as well as #including the header.
>
> : gcc -lm ...
>
> The "0lm" trick sure did it. Just tested it on another virtual console.
> Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?
>

Becuase Pi radians = 1 complete circle.

radians are a "unitless" type of unit, and therefore, the standard.


> --
> FOOD FOR THOUGHT: 100 calories are used up in the course of a mile run.
> The USDA guidelines for dietary fibre is equal to one ounce of sawdust.
> The liver makes the vast majority of the cholesterol in your bloodstream.

--

Mark McIntyre

unread,
Feb 24, 2001, 8:13:56 PM2/24/01
to
On Sat, 24 Feb 2001 20:06:41 -0500, Aaron Kulkis <aku...@yahoo.com>
wrote:

>
>
>-hs- wrote:
>>
>>
>> Are you awared that the recommend maximum length for a .sig is 4 lines?
>>
>
>Are you aware that this suggestion was formulated during the days
>before fiber-optics, when MFM and RLL were not even invented yet,
>and the ARPA-NET backbone had a 56k bandwidth and 20 megabyte disks
>were considered huge...

Are you aware that by posting a large sig you are wasting your and
other people's money, not to say bandwidth, and therefore causing them
to killfile you?

go away you jerk

*plonk*


--
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>

Dan Pop

unread,
Feb 24, 2001, 7:46:24 PM2/24/01
to
In <9790vd$4od$2...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:

>Here's a chance to correct (and flame) me. Last time I checked, a full circle
>is 3.1415926.... radians, that being pi number radians to equal 360 degrees.

It must have shrinked in the meantime. It used to be 2 * 3.1415926...
radians back when I was in highschool.

Dan ;-)

Edward Rosten

unread,
Feb 24, 2001, 8:21:06 PM2/24/01
to
> There are 2 pi radians in a full circle, so the conversion is pi /
> 180.0:
>
> double deg_to_rad(double degrees)
> {
> return degrees * 3.14159265358979323846 / 180.0;
> }


It would be easier to use M_PIl as #defined in math.h

-Ed

J Sloan

unread,
Feb 24, 2001, 8:48:46 PM2/24/01
to
Aaron Kulkis wrote:

> Bloody Viking wrote:
>
> > Here's a chance to correct (and flame) me. Last time I checked, a full circle
> > is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
> > Time to add the conversion line to my little programme.
> >
>
> correct. Pi radians = one circle.

I could swear that should be 2 pi radians.

Rough check: 1 radian =~ 57.3 degrees

2 pi =~ 6.28

2 pi X 1 radian =~ 360 degrees

jjs


Dann Corbit

unread,
Feb 24, 2001, 9:02:45 PM2/24/01
to
"Aaron Kulkis" <aku...@yahoo.com> wrote in message
news:3A985B80...@yahoo.com...

>
> Bloody Viking wrote:
> >
> > -hs- (email....@server.invalid) wrote:
> >
> > : To avoid the question "Why isn't it in radians as is the standard?"
> >
> > So, it is in radians. Now that I know about the "-lm" switch for the
compile,
> > I get to make a degree2radian conversion line to add to my code. Something
> > off-topic is that the TI-86 calculator out of the box defaults to radians.
> > (you set it to degrees)
> >
> > Here's a chance to correct (and flame) me. Last time I checked, a full
circle
> > is 3.1415926.... radians, that being pi number radians to equal 360
degrees.
> > Time to add the conversion line to my little programme.
> >
>
> correct. Pi radians = one circle.


Are you the guy with the monkey who throws peanuts at his girlfriends? If you
really have no idea whatsoever about that which you are talking about, why
bother to chime in at all?

I see someone else has already plonked you (and I merely hovered...), and I
also shall
*plonk*
and if a *plonk* is equal to pi, then we really have come full circle haven't
we?
--
C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
"The C-FAQ Book" ISBN 0-201-84519-9
C.A.P. FAQ: ftp://cap.connx.com/pub/Chess%20Analysis%20Project%20FAQ.htm


Edward Rosten

unread,
Feb 24, 2001, 9:18:28 PM2/24/01
to
>> Here's a chance to correct (and flame) me. Last time I checked, a full
>> circle is 3.1415926.... radians, that being pi number radians to equal
>> 360 degrees. Time to add the conversion line to my little programme.
>>
>
> correct. Pi radians = one circle.

No.

There are 2*pi radians in a circle.

Dave Vandervies

unread,
Feb 24, 2001, 9:22:29 PM2/24/01
to
In article <979mmq$i3t$1...@news.ox.ac.uk>, Edward Rosten <lo...@my.sig> wrote:
>> There are 2 pi radians in a full circle, so the conversion is pi /
>> 180.0:
>>
>> double deg_to_rad(double degrees)
>> {
>> return degrees * 3.14159265358979323846 / 180.0;
>> }
>
>
>It would be easier to use M_PIl as #defined in math.h

Really?

--------
dj3vande@mef08:~ (0) $ cat > foo.c
#include <math.h>

double deg2rad(double degrees) )
{
return deg * M_PIl / 180;
}
dj3vande@mef08:~ (0) $ gcc -W -Wall -ansi -pedantic -O -c foo.c
foo.c: In function `deg2rad':
foo.c:5: `M_PIl' undeclared (first use in this function)
foo.c:5: (Each undeclared identifier is reported only once
foo.c:5: for each function it appears in.)
foo.c:6: warning: control reaches end of non-void function
dj3vande@mef08:~ (1) $
--------

Funny, it doesn't seem to be defined in _my_ math.h...


dave

--
Dave Vandervies dj3v...@student.math.uwaterloo.ca
There is really no need to reconcile them. What the Standard says defines the
C language. The FAQ attempts to explain it in a form mere mortals can
understand. :-) --Chris Torek in comp.lang.c

Bloody Viking

unread,
Feb 24, 2001, 9:55:59 PM2/24/01
to

Richard Heathfield (bin...@eton.powernet.co.uk) wrote:

: Not just yet! :-)

: There are 2 pi radians in a full circle, so the conversion is pi /
: 180.0:

After I posted to the thread I fired up a web search engine and sure enough, a
full circle is 2*pi radians.

The degrees to radians conversion - which I added to my proggie - is
pathetically simple:

Degrees == 2 * pi / 360

If you want to save a few CPU cycles, you could use variable * .0174532 to do
the same conversion. I chose, becuse saving a few CPU cycles wasn't important
this conversion:

angle = angle / 360 * 2 * 3.14159268;

I tried it out and it works perfectly. A sine for a 30 degree angle comes out
to be .500000 as to be expected. So, with adding in math.h and compiling with
-lm I can now get my computer to do trig as I please.

Trig, once appreciated, is actually useful. It can be used to reverse-engineer
prescriptions for glasses for the nearsighted for example. It can be used for
ballistics too. Yep, you can "go ballistic" with creative use of trig.

Vector stuff involves 3-D trig in lots of cases. Ray-tracing uses a LOT of
trig as each "ray" computed is a 3-D vector to be triangulated in both up and
down AND left and right. So, while my use of trig is trivial by comparison, I
do know its significance.

Dan Pop

unread,
Feb 24, 2001, 9:50:02 PM2/24/01
to
In <979mmq$i3t$1...@news.ox.ac.uk> "Edward Rosten" <lo...@my.sig> writes:

>> There are 2 pi radians in a full circle, so the conversion is pi /
>> 180.0:
>>
>> double deg_to_rad(double degrees)
>> {
>> return degrees * 3.14159265358979323846 / 180.0;
>> }
>
>It would be easier to use M_PIl as #defined in math.h

<math.h> has no licence to define such a macro when the compiler is
invoked in conforming mode.

Dan

Bloody Viking

unread,
Feb 24, 2001, 10:15:37 PM2/24/01
to

Dan Pop (Dan...@cern.ch) wrote:

: In <978a64$r1q$1...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:

: >Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?

: What standard?!?

The Industry Standard. While high-end math pros might use radians, normal
people always use degrees to measure an angle. For all intents and purposes
degrees IS the standard. Even astronomers use degrees, "minutes", and
"seconds". As far as I care, degrees, minutes, and seconds ARE the Industry
Standard. Radians are not.

It's not too big a deal, certainly when you can readily convert between
degrees and radians. I will merely have to add in a conversion line into any C
proggie to convert from the Industry Standard degrees to the radians.

Almost certainly, who coded the math.h library was a high-end math pro, which
would make sense. Since those people like radians, they simply forgot degrees
support, since the conversion is so easy. No complaint here, only a small
inconvience that I done corrected.

The little "problem" I encountered and got help on is pretty damn esoteric.
Really, how many home users would ever ask about such a seeming "bug"? I can't
help but ask if other non-bugs are there solvable by adding a switch for the
compile.

Bloody Viking

unread,
Feb 24, 2001, 10:25:40 PM2/24/01
to

Aaron Kulkis (aku...@yahoo.com) wrote:

: radians are a "unitless" type of unit, and therefore, the standard.

A full circle is 2 * pi. Still, it's a "unitless" unit. In any case, I found a
working solution to my pet problem by using a conversion formula. My proggie
works just fine now. Time to code up a proggie for the launch of an arbitrary
projectile, like a car off a jump ramp.

That fun problem has the further challenge of taking into account the attitude
of the car during ballistic flight. Air friction only adds more math fun! Use
fins for attitude control for ballistic flight across the Grand Canyon.

Bloody Viking

unread,
Feb 24, 2001, 10:43:41 PM2/24/01
to

Dann Corbit (dco...@solutionsiq.com) wrote:

: Are you the guy with the monkey who throws peanuts at his girlfriends? If you


: really have no idea whatsoever about that which you are talking about, why
: bother to chime in at all?

Aaron Kulkus doesn't seem all that comfortable knowing that we humans did come
from an old version of an ape, let alone a monkey.

After all, that hair on your arm serves two purposes:

A: It gives laser docs job security.

B: It's an annoying reminder that we did come from a furred ape.

Want to see a furred person? Check this out:

http:www.luna.co.uk/~charles/

He's a Brit with a full Darwin fur coat like an orangutan! Yes, we DID climb
down from the trees. Why else would kids try climbing trees? Whether you like
it or not, we did come from a prehistoric ape, and that ape was the
human/chimpanzee precursor ape.

If you have a high-speed SUV outfitted with a flux cap, you can meet your
great^300,000 grandparent. He or she will look about like a modern chimp but
with arm length similar to our own.

Dan Pop

unread,
Feb 24, 2001, 11:11:58 PM2/24/01
to
In <979tcp$e0r$1...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:


>Dan Pop (Dan...@cern.ch) wrote:
>: In <978a64$r1q$1...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:
>
>: >Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?
>
>: What standard?!?
>
>The Industry Standard.

Where can I get this standard from?

>While high-end math pros might use radians, normal
>people always use degrees to measure an angle.

Normal people don't normally deal with the sine and cosine values of the
angles they measure.

Degrees are a meaningless unit in trigonometry, which is not exactly
high end math. I've learned most of it in junior high school.

>For all intents and purposes
>degrees IS the standard. Even astronomers use degrees, "minutes", and
>"seconds". As far as I care, degrees, minutes, and seconds ARE the Industry
>Standard. Radians are not.

I was not aware that you're the one who makes the industry standards.

OTOH, *all* the programming languages that I'm familiar with use radians
for the arguments of the trigonometric functions. So, I'm tempted to
believe that they're the standard in the computing industry. I'm also
tempted to believe that there must be a good reason for that.

Charles Lyttle

unread,
Feb 24, 2001, 11:12:39 PM2/24/01
to
circumfrence = 2*pi*radius

1 radian is the angle subtended by a segment of the circumfrence equal
in length to the radius. Therefore there are 2*pi radians in a circle.
--
Russ Lyttle
lyt...@eartink.net
<http://home.earthlink.net/~lyttlec>

Ray Chason

unread,
Feb 24, 2001, 11:32:37 PM2/24/01
to
comp.os.linux.advocacy snecked.

nos...@ripco.com (Bloody Viking) wrote:

>The degrees to radians conversion - which I added to my proggie - is
>pathetically simple:
>
>Degrees == 2 * pi / 360
>
>If you want to save a few CPU cycles, you could use variable * .0174532 to do
>the same conversion. I chose, becuse saving a few CPU cycles wasn't important
>this conversion:
>
>angle = angle / 360 * 2 * 3.14159268;

Any self-respecting compiler can optimize this so that only one
operation is performed.

If you're worried about CPU cycles, you would do well to keep all
angles in radians within your program, unless you have a specific
reason to do otherwise. Convert to or from degrees in user interface
code only.

Even better is knowing the various trigonometric identities. You can
also optimize by saving the output of a trig function if you use it
more than once. A useful rule is that a trig function, or other
transcendental function such as exp(), takes more time than any
number of additions or multiplications.


--
--------------===============<[ Ray Chason ]>===============--------------
PGP public key at http://www.smart.net/~rchason/pubkey.asc
Delenda est Windoze

Ray Chason

unread,
Feb 24, 2001, 11:37:24 PM2/24/01
to
comp.os.linux.advocacy dropped.

nos...@ripco.com (Bloody Viking) wrote:

>When I compiled it up with the switch, I got an unexpected answer, as I used
>45 for the angle, expecting degrees as the default, which would be .707... as
>opposed to .850904. It looks like gcc uses radians. No matter, you slip in a
>conversion line. (:

All implementations of C use radians for all trig functions. It's in
the ISO standard, and was also in pre-ISO/ANSI implementations of C.

Ray Chason

unread,
Feb 24, 2001, 11:40:52 PM2/24/01
to
"-hs-" <email....@server.invalid> wrote:

>Aaron Kulkis a écrit dans le message <3A979BFE...@yahoo.com>...

[Aaron Kulkis's Big Wanking Spam Sig]

>Are you awared that the recommend maximum length for a .sig is 4 lines?

Kulkis claims that he has a lot of enemies, and that his Big Wanking
Spam Sig somehow sprinkles magic pixie dust over your newsgroup to
keep them away.

He will not listen to reason. I killfiled him long ago, and suggest
that you do the same.

Dave Vandervies

unread,
Feb 24, 2001, 11:41:14 PM2/24/01
to
In article <979q95$6dk$1...@watserv3.uwaterloo.ca>,

Dave Vandervies <dj3v...@student.math.uwaterloo.ca> wrote:
>
>Really?
>
>--------
>dj3vande@mef08:~ (0) $ cat > foo.c
>#include <math.h>
>
>double deg2rad(double degrees) )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That line was supposed to be
double deg2rad(double deg)
but it appears that my editor decided to interpret the backspaces the
way cat did when I typed them instead of showing them to me so that I
could clean them up.


>{
> return deg * M_PIl / 180;
>}
>dj3vande@mef08:~ (0) $ gcc -W -Wall -ansi -pedantic -O -c foo.c
>foo.c: In function `deg2rad':
>foo.c:5: `M_PIl' undeclared (first use in this function)
>foo.c:5: (Each undeclared identifier is reported only once
>foo.c:5: for each function it appears in.)
>foo.c:6: warning: control reaches end of non-void function
>dj3vande@mef08:~ (1) $
>--------
>
>Funny, it doesn't seem to be defined in _my_ math.h...


dave

--
Dave Vandervies dj3v...@student.math.uwaterloo.ca
We always tell people NOT to mess with their headers, and what do you
do? You go and mess with your headers. Honestly, I despair sometimes.
--Richard Heathfield flames Dan Pop in comp.lang.c

Richard Heathfield

unread,
Feb 25, 2001, 2:16:39 AM2/25/01
to
z00t wrote:
>
> -hs- wrote:
> > z00t a écrit dans le message <978uq...@news1.newsguy.com>...
> > >
> > >You should zero errno before calling strtod(). [...]
> >
> >
> > I am not sure. Do you meant that strdod() doesn't set errno to 0 if no
> > error?
> >
> Yes.
> [#3] The value of errno is zero at program startup, but is
> never set to zero by any library function.
>
> (from n869. but i believe it was the same in the previous Standart
> and is still the same)

The wording is identical in the final standard. This footnote may
clarify matters for -hs- somewhat:

170) Thus, a program that uses errno for error checking should set it to
zero before a library function call,
then inspect it before a subsequent library function call. Of course, a
library function can save the
value of errno on entry and then set it to zero, as long as the original
value is restored if errno’s
value is still zero just before the return.

--
Richard Heathfield
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton

Richard Heathfield

unread,
Feb 25, 2001, 2:18:45 AM2/25/01
to
Aaron Kulkis wrote:
>
> > Are you awared that the recommend maximum length for a .sig is 4 lines?
> >
>
> Are you aware that this suggestion was formulated during the days
> before fiber-optics, when MFM and RLL were not even invented yet,
> and the ARPA-NET backbone had a 56k bandwidth and 20 megabyte disks
> were considered huge...

Are you aware that some of us are still using 28.8 modems and paying by
the minute for our dialup connections, and that any saving is thus most
welcome?

If you answer, please remove your sig block before so doing.

Tim Hanson

unread,
Feb 25, 2001, 2:59:05 AM2/25/01
to
Aaron Kulkis wrote:
>
> Bloody Viking wrote:
> >
> > Edward Rosten (lo...@my.sig) wrote:
> >
> > : Those are perfectly normal errors: you have no cos function. You need to
> > : link against the maths library as well as #including the header.
> >
> > : gcc -lm ...
> >
> > The "0lm" trick sure did it. Just tested it on another virtual console.
> > Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?
> >
>
> Becuase Pi radians = 1 complete circle.
>

Nope. C = pi 2r = pi d.

--
Vila: "I think I have just made the biggest mistake of my life."
Orac: "It is unlikely. I would predict there are far greater mistakes
waiting to be made by someone with your obvious talent for it."

Richard Heathfield

unread,
Feb 25, 2001, 2:59:07 AM2/25/01
to
Bloody Viking wrote:
>
<snip>

>
> He's a Brit with a full Darwin fur coat like an orangutan! Yes, we DID climb
> down from the trees. Why else would kids try climbing trees? Whether you like
> it or not, we did come from a prehistoric ape, and that ape was the
> human/chimpanzee precursor ape.
>
> If you have a high-speed SUV outfitted with a flux cap, you can meet your
> great^300,000 grandparent. He or she will look about like a modern chimp but
> with arm length similar to our own.

This is nothing to do with either C or Linux.

Followups set to talk.origins.

Joona I Palaste

unread,
Feb 25, 2001, 3:16:28 AM2/25/01
to
Aaron Kulkis <aku...@yahoo.com> scribbled the following
on comp.lang.c:


> Bloody Viking wrote:
>>
>> -hs- (email....@server.invalid) wrote:
>>
>> : To avoid the question "Why isn't it in radians as is the standard?"
>>
>> So, it is in radians. Now that I know about the "-lm" switch for the compile,
>> I get to make a degree2radian conversion line to add to my code. Something
>> off-topic is that the TI-86 calculator out of the box defaults to radians.
>> (you set it to degrees)
>>
>> Here's a chance to correct (and flame) me. Last time I checked, a full circle
>> is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
>> Time to add the conversion line to my little programme.
>>

> correct. Pi radians = one circle.

Both of you are wrong. One circle equals 2*Pi radians.

--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/

"This is a personnel commuter."
- Train driver in Scientific American

Joona I Palaste

unread,
Feb 25, 2001, 3:18:12 AM2/25/01
to
Aaron Kulkis <aku...@yahoo.com> scribbled the following
on comp.lang.c:
> Becuase Pi radians = 1 complete circle.

> radians are a "unitless" type of unit, and therefore, the standard.

Stop repeating the same nonsense over and over again.

--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/

"Shh! The maestro is decomposing!"
- Gary Larson

Richard Heathfield

unread,
Feb 25, 2001, 3:30:58 AM2/25/01
to
Joona I Palaste wrote:
>
> >> Here's a chance to correct (and flame) me. Last time I checked, a full circle
> >> is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
> >> Time to add the conversion line to my little programme.
> >>
>
> > correct. Pi radians = one circle.
>
> Both of you are wrong. One circle equals 2*Pi radians.

That's not true either. ITYM *ALL* circles. :-)

Dave Vandervies

unread,
Feb 25, 2001, 3:57:13 AM2/25/01
to
In article <3A98C2C...@eton.powernet.co.uk>,

Richard Heathfield <bin...@eton.powernet.co.uk> wrote:
>Joona I Palaste wrote:
>>
>> >> Here's a chance to correct (and flame) me. Last time I checked, a full circle
>> >> is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
>> >> Time to add the conversion line to my little programme.
>> >>
>>
>> > correct. Pi radians = one circle.
>>
>> Both of you are wrong. One circle equals 2*Pi radians.
>
>That's not true either. ITYM *ALL* circles. :-)

...but only one at a time. n circles taken together makes 2*Pi*n radians.

-hs-

unread,
Feb 25, 2001, 5:00:53 AM2/25/01
to
Richard Heathfield a écrit dans le message
<3A98B157...@eton.powernet.co.uk>...

>> > >You should zero errno before calling strtod(). [...]
>> >
>> >
>> > I am not sure. Do you meant that strdod() doesn't set errno to 0 if no
>> > error?
>> >
>> Yes.
>> [#3] The value of errno is zero at program startup, but is
>> never set to zero by any library function.
>>
>> (from n869. but i believe it was the same in the previous Standart
>> and is still the same)
>
>The wording is identical in the final standard. This footnote may
>clarify matters for -hs- somewhat:
>
>170) Thus, a program that uses errno for error checking should set it to
>zero before a library function call,
>then inspect it before a subsequent library function call. Of course, a
>library function can save the
>value of errno on entry and then set it to zero, as long as the original
>value is restored if errno’s
>value is still zero just before the return.

All right, I've got the imprimatur, so:

{
char *p;

errno = 0;
result = strtod (s, &p);

if (errno)
{
perror(FUNCTION);
}

if (p == s)
{
fprintf(stderr, FUNCTION": Input error\n");
}
}

--
-hs- Tabs out, spaces in.
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
FAQ de FCLC : http://www.isty-info.uvsq.fr/~rumeau/fclc


Edward Rosten

unread,
Feb 25, 2001, 5:41:45 AM2/25/01
to
In article <979q95$6dk$1...@watserv3.uwaterloo.ca>, "Dave Vandervies"
<dj3v...@student.math.uwaterloo.ca> wrote:

> In article <979mmq$i3t$1...@news.ox.ac.uk>, Edward Rosten <lo...@my.sig>
> wrote:
>>> There are 2 pi radians in a full circle, so the conversion is pi /
>>> 180.0:
>>>
>>> double deg_to_rad(double degrees)
>>> {
>>> return degrees * 3.14159265358979323846 / 180.0;
>>> }
>>
>>
>>It would be easier to use M_PIl as #defined in math.h
>
> Really?

Oh. I assumed that because it was in mine, it would be in everyones. Try
searching math.h for PI.

If you don't have one, then take this nice long definition (from my
math.h) an put it in pi.h or something.

3.1415926535897932384626433832795029L


> double deg2rad(double degrees))


> {
> return deg * M_PIl / 180;
> }

Wouldn't it be better to have this as a macro, It wouldn't icrease the
program size by much, but it would be faster.

-ed

Edward Rosten

unread,
Feb 25, 2001, 5:42:51 AM2/25/01
to
In article <979rsq$c3s$1...@sunnews.cern.ch>, "Dan Pop" <Dan...@cern.ch>
wrote:

> In <979mmq$i3t$1...@news.ox.ac.uk> "Edward Rosten" <lo...@my.sig> writes:
>
>>> There are 2 pi radians in a full circle, so the conversion is pi /
>>> 180.0:
>>>
>>> double deg_to_rad(double degrees)
>>> {
>>> return degrees * 3.14159265358979323846 / 180.0;
>>> }
>>
>>It would be easier to use M_PIl as #defined in math.h
>
> <math.h> has no licence to define such a macro when the compiler is
> invoked in conforming mode.

Is there an official place where a definition of PI is meant to reside?


-Ed

CBFalconer

unread,
Feb 25, 2001, 6:23:54 AM2/25/01
to
Dan Pop wrote:

>
> In <9790vd$4od$2...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:
>
> >Here's a chance to correct (and flame) me. Last time I checked, a full circle
> >is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
>
> It must have shrinked in the meantime. It used to be 2 * 3.1415926...
^^^^^^^^
Gotcha :-). Your perfect English failed. The irregular usage is
"shrunk" or "shrank".

> radians back when I was in highschool.


--
Chuck F (cbfal...@my-deja.com) (cbfal...@XXXXworldnet.att.net)
http://www.qwikpages.com/backstreets/cbfalconer
(Remove "NOSPAM." from reply address. my-deja works unmodified)
mailto:u...@ftc.gov (for spambots to harvest)


Mark McIntyre

unread,
Feb 25, 2001, 7:29:04 AM2/25/01
to
On 25 Feb 2001 04:11:58 GMT, Dan...@cern.ch (Dan Pop) wrote:

>In <979tcp$e0r$1...@gail.ripco.com> nos...@ripco.com (Bloody Viking) writes:
>
>>For all intents and purposes
>>degrees IS the standard. Even astronomers use degrees, "minutes", and
>>"seconds".

Curiously enough, astronomers use *hours*, minutes and seconds, at
least for RA and one minute of RA is not equal to one minute of arc.
So Viking's assertion is factually as well as actually wrong....


--
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>

Lawrence Kirby

unread,
Feb 25, 2001, 8:10:41 AM2/25/01
to
In article <9791qg$5aa$1...@gail.ripco.com> nos...@ripco.com "Bloody Viking" writes:

>
>gou...@email.com wrote:
>
>: In short, radians are more often used in mathematics. Radians do have
>: some useful properties, particularly in keeping formulae simple (eg the
>: area of a segment of a circle is rT, where r is the radius and T is the
>: angle in radians subtended at the centre, if T is in degrees there is an
>: ugly constant involved)
>
>So, THAT'S why radians are used by high-end mathematicians. The "ugly
>constant" as you describe is the degrees to radians conversion constant, which
>will be pi/360. That feature of radians would be useful for orbital mechanics
>whereby at perigee the area of satellite motion and the planet's centre of
>gravity over a second will equal that area at apogee, so you can determine
>speed at the any point in an orbit if you know it at any one spot.

It is also very useful in many other areas of mathematics. Your observation
is not entirely unrelated to the fact that in calculus the differential of
sin(x) is cos(x), and the differential of cos(x) is -sin(x) when x is
measured in radians. Basically if you are a mathematician doing anything
nontrivial in this area you would be crazy to work with anything other
than radians.

As far as programming languages go thre are a couple of points

1. It is marginally easier to implement trig functions in radians than
in any other scale.

2. If the language works in radians then the program it may have to provide
conversions to othe scales on input and output. If the language works
in something else the program may have to apply correction factors
throughout its calculations. This is potentially much more significant
than 1.

>A fun factoid is that orbital mechanics was once called "celestial mechanics"
>but is now too useful to us Earthlings as we launch all manner of small
>functional "moons" to the point Earth has a ring 22,300 miles up.
>(geosynchronous orbit) Newton never figured that his "celectial mechanics"
>would be of _military_ significance. (spy sats)

I suspect that most spy satellites are in low orbit. You can see things
in much more detail from a couple of hundred miles up than you can
from 22000 miles.

--
-----------------------------------------
Lawrence Kirby | fr...@genesis.demon.co.uk
Wilts, England | 7073...@compuserve.com
-----------------------------------------

Lawrence Kirby

unread,
Feb 25, 2001, 8:23:43 AM2/25/01
to
In article <3A980D6F...@eton.powernet.co.uk>
bin...@eton.powernet.co.uk "Richard Heathfield" writes:

...

>Not just yet! :-)


>
>There are 2 pi radians in a full circle, so the conversion is pi /
>180.0:
>
>double deg_to_rad(double degrees)
>{
> return degrees * 3.14159265358979323846 / 180.0;

Although I'd prefer to write that as

return degrees * (3.14159265358979323846 / 180.0);

There's no point in forcing unnecessary runtime divisions.

Lawrence Kirby

unread,
Feb 25, 2001, 8:26:36 AM2/25/01
to
In article <979mmq$i3t$1...@news.ox.ac.uk> lo...@my.sig "Edward Rosten" writes:

>> There are 2 pi radians in a full circle, so the conversion is pi /
>> 180.0:
>>
>> double deg_to_rad(double degrees)
>> {
>> return degrees * 3.14159265358979323846 / 180.0;
>> }
>
>

>It would be easier to use M_PIl as #defined in math.h

Any compiler that defines that or anything similar in a standard header
is in direct violation of the C standard.

Lawrence Kirby

unread,
Feb 25, 2001, 8:27:33 AM2/25/01
to
In article <t9h2n5s...@corp.supernews.com>
johnn...@southland.smart.net.SPAMMEN.VERBOTEN "Ray Chason" writes:

>comp.os.linux.advocacy snecked.
>
>nos...@ripco.com (Bloody Viking) wrote:
>
>>The degrees to radians conversion - which I added to my proggie - is
>>pathetically simple:
>>
>>Degrees == 2 * pi / 360
>>
>>If you want to save a few CPU cycles, you could use variable * .0174532 to do
>>the same conversion. I chose, becuse saving a few CPU cycles wasn't important
>>this conversion:
>>
>>angle = angle / 360 * 2 * 3.14159268;
>
>Any self-respecting compiler can optimize this so that only one
>operation is performed.

No, it can't. It may be able to combine the multiplication by 2 with
something else but only because multiplications by powers of 2 can
usually be guaranteed exact on binary floating point systems. The
standard explains the issue well enough:

"Rearrangement of floating point expressions is often restricted because
of limitations in precision as well as range. The implementation cannot
generally apply the mathematical associative rules for addition or
multiplication, nor the distributive rule, because of roundoff error,
even in the absense of overflow and underflow. Likewise implementations
cannot generally replace decimal constants in order to rearrange
expressions."

Gregory Pietsch

unread,
Feb 25, 2001, 10:57:35 AM2/25/01
to
Edward Rosten wrote:

No.

Gregory Pietsch

mlw

unread,
Feb 25, 2001, 11:11:52 AM2/25/01
to
Lawrence Kirby wrote:
>
> In article <3A980D6F...@eton.powernet.co.uk>
> bin...@eton.powernet.co.uk "Richard Heathfield" writes:
>
> ...
>
> >Not just yet! :-)
> >
> >There are 2 pi radians in a full circle, so the conversion is pi /
> >180.0:
> >
> >double deg_to_rad(double degrees)
> >{
> > return degrees * 3.14159265358979323846 / 180.0;
>
> Although I'd prefer to write that as
>
> return degrees * (3.14159265358979323846 / 180.0);
>
> There's no point in forcing unnecessary runtime divisions.

Actually, you should do it this way:

return (degrees * 3.14159265358979323846) / 180.0;

This will preserve more precision.


--
The majority of the stupid is invincible and guaranteed for all time.
The terror of their tyranny, however, is alleviated by their lack of
consistency.
-- Albert Einstein
------------------------
http://www.mohawksoft.com

Tor Rustad

unread,
Feb 25, 2001, 11:29:00 AM2/25/01
to
"Edward Rosten" <lo...@my.sig> wrote in message

No trace of it in the standard, and I also checked the header directory without
any luck.

I think the problem is that you are *not* using your C compiler in ANSI mode.

--
Tor <torust AT online DOT no>


Ian Woods

unread,
Feb 25, 2001, 11:32:16 AM2/25/01
to
nos...@ripco.com (Bloody Viking) wrote in <979tvk$e0r$2...@gail.ripco.com>:

>
>Aaron Kulkis (aku...@yahoo.com) wrote:
>
>: radians are a "unitless" type of unit, and therefore, the standard.
>
>A full circle is 2 * pi. Still, it's a "unitless" unit. In any case, I
>found a working solution to my pet problem by using a conversion
>formula. My proggie works just fine now. Time to code up a proggie for
>the launch of an arbitrary projectile, like a car off a jump ramp.
>
>That fun problem has the further challenge of taking into account the
>attitude of the car during ballistic flight. Air friction only adds more
>math fun! Use fins for attitude control for ballistic flight across the
>Grand Canyon.

I think anyone willing to do that should be a nominee for a Darwin award.

Ian Woods

Chris Kern

unread,
Feb 25, 2001, 11:26:40 AM2/25/01
to
On Sat, 24 Feb 2001 22:51:14 +0000, gou...@email.com posted the
following:

>Chris Kern wrote:
>>
>> On 24 Feb 2001 12:41:40 GMT, nos...@ripco.com (Bloody Viking) posted
>> the following:


>>
>> > Why isn't it in degrees as is the standard?
>>

>> While degrees may be the standard for many people, mathemeticians
>> always (or nearly always) use radians.
>>
>> -Chris
>
>*real* mathematicians don't really care

real mathemeticians don't bother with calculations of things like
degrees and radians. Group theory doesn't generally deal in circles
;)

-Chris

Edward Rosten

unread,
Feb 25, 2001, 12:29:08 PM2/25/01
to
>> Is there an official place where a definition of PI is meant to reside?
>
> No trace of it in the standard, and I also checked the header directory
> without any luck.
>
> I think the problem is that you are *not* using your C compiler in ANSI
> mode.

No, probably not. I was just doing a text search for PI in math.h. I
didn't think to check it with the compiler.

It doesn't work unless __USE_BSD || __USE_XOPEN (for short ones) or
__USE_GNU (for long defs) has been defined.

Edward Rosten

unread,
Feb 25, 2001, 12:37:27 PM2/25/01
to
>>That fun problem has the further challenge of taking into account the
>>attitude of the car during ballistic flight. Air friction only adds more
>>math fun! Use fins for attitude control for ballistic flight across the
>>Grand Canyon.
>
> I think anyone willing to do that should be a nominee for a Darwin
> award.

Only if they remove themselves from the gene pool in the process.

-ed

Bob Hauck

unread,
Feb 25, 2001, 12:43:40 PM2/25/01
to
On Sun, 25 Feb 2001 15:57:35 GMT, Gregory Pietsch <gk...@flash.net> wrote:
>Edward Rosten wrote:

>> Is there an official place where a definition of PI is meant to reside?
>
>No.

How about in the trig functions:

#define A_PI (4 * atan (1))
#define B_PI (2 * asin (1))
#define C_PI (2 * acos (0))

--
-| Bob Hauck
-| To Whom You Are Speaking
-| http://www.haucks.org/

-hs-

unread,
Feb 25, 2001, 1:57:13 PM2/25/01
to
Bob Hauck a écrit dans le message ...

>On Sun, 25 Feb 2001 15:57:35 GMT, Gregory Pietsch <gk...@flash.net> wrote:
>>Edward Rosten wrote:
>
>>> Is there an official place where a definition of PI is meant to reside?
>>
>>No.
>
>How about in the trig functions:
>
>#define A_PI (4 * atan (1))
>#define B_PI (2 * asin (1))
>#define C_PI (2 * acos (0))

For the records

Borland C 3.1

A_PI = 3.14159265358979312000
B_PI = 3.14159265358979312000
C_PI = 3.14159265358979312000

DJGPP (gcc)
A_PI = 3.14159265358979311600
B_PI = 3.14159265358979311600
C_PI = 3.14159265358979311600

Test program:

#include <stdio.h>
#include <math.h>

#define A_PI (4 * atan (1.0))
#define B_PI (2 * asin (1.0))
#define C_PI (2 * acos (0.0))

int main (void)
{
printf ("A_PI = %.20f\n", A_PI);
printf ("B_PI = %.20f\n", B_PI);
printf ("C_PI = %.20f\n", C_PI);
return 0;

Bloody Viking

unread,
Feb 25, 2001, 3:02:08 PM2/25/01
to

Edward Rosten (lo...@my.sig) wrote:
: >>That fun problem has the further challenge of taking into account the

: >>attitude of the car during ballistic flight. Air friction only adds more
: >>math fun! Use fins for attitude control for ballistic flight across the
: >>Grand Canyon.

: > I think anyone willing to do that should be a nominee for a Darwin
: > award.

: Only if they remove themselves from the gene pool in the process.

That's why you do your homework prior to your flight. (and no, I'm not going
to attempt the flight even after doing the homework)

Bloody Viking

unread,
Feb 25, 2001, 3:11:39 PM2/25/01
to

Dan Pop (Dan...@cern.ch) wrote:

: Degrees are a meaningless unit in trigonometry, which is not exactly
: high end math. I've learned most of it in junior high school.

Trig is not high-end math at all. You're right. But when it is taught, it is
taught using degrees for the angles, never radians.

: OTOH, *all* the programming languages that I'm familiar with use radians
: for the arguments of the trigonometric functions. So, I'm tempted to
: believe that they're the standard in the computing industry. I'm also
: tempted to believe that there must be a good reason for that.

Most normal people never take up programming computers. Working-class people
who programme for amusement are about as rare as humans with full-scale fur
coats.

Ben Pfaff

unread,
Feb 25, 2001, 3:15:23 PM2/25/01
to
nos...@ripco.com (Bloody Viking) writes:

> Dan Pop (Dan...@cern.ch) wrote:
>
> : Degrees are a meaningless unit in trigonometry, which is not exactly
> : high end math. I've learned most of it in junior high school.
>
> Trig is not high-end math at all. You're right. But when it is taught, it is
> taught using degrees for the angles, never radians.

Not true. I was taught trig using both systems of angle
measurement. There was probably more emphasis on radian
measurement, in fact.
--
"Large amounts of money tend to quench any scruples I might be having."
-- Stephan Wilms

Edward Rosten

unread,
Feb 25, 2001, 3:25:29 PM2/25/01
to
In article <slrn99ieo...@nebo.haucks.org>, "Bob Hauck"
<b...@this-is.invalid> wrote:

> On Sun, 25 Feb 2001 15:57:35 GMT, Gregory Pietsch <gk...@flash.net>
> wrote:
>>Edward Rosten wrote:
>
>>> Is there an official place where a definition of PI is meant to
>>> reside?
>>
>>No.
>
> How about in the trig functions:
>
> #define A_PI (4 * atan (1))
> #define B_PI (2 * asin (1))
> #define C_PI (2 * acos (0))

No, that would be horribly slow, calculating PI every time you needed it.
You'd be better off pulling a numeric constant for PI off some website
and using a #define.

Besides, despite not being in the standard, most compilers probably come
with a definition for PI. If you wanted portability, you could just get
the number and put it in your own #define or const.

Mark McIntyre

unread,
Feb 25, 2001, 3:57:36 PM2/25/01
to
On Sun, 25 Feb 2001 13:26:36 GMT, fr...@genesis.demon.co.uk (Lawrence
Kirby) wrote:

>In article <979mmq$i3t$1...@news.ox.ac.uk> lo...@my.sig "Edward Rosten" writes:
>
>>> There are 2 pi radians in a full circle, so the conversion is pi /
>>> 180.0:
>>>
>>> double deg_to_rad(double degrees)
>>> {
>>> return degrees * 3.14159265358979323846 / 180.0;
>>> }
>>
>>
>>It would be easier to use M_PIl as #defined in math.h
>
>Any compiler that defines that or anything similar in a standard header
>is in direct violation of the C standard.

I'm not sure that this is strictly true - don't you mean "any compiler
that defines this in the standard header, when compiled in strict ansi
mode, is violating the standard, What the compiler defines in
ansi-with-extensions mode is its own business".

Mark McIntyre

unread,
Feb 25, 2001, 3:59:00 PM2/25/01
to
On Sun, 25 Feb 2001 16:26:40 GMT, ke...@grinnell.edu (Chris Kern)
wrote:

Bet you occasionally work with elliptical surfaces tho...

Mark McIntyre

unread,
Feb 25, 2001, 4:00:51 PM2/25/01
to
On 25 Feb 2001 20:11:39 GMT, nos...@ripco.com (Bloody Viking) wrote:

>
>Dan Pop (Dan...@cern.ch) wrote:
>
>: Degrees are a meaningless unit in trigonometry, which is not exactly
>: high end math. I've learned most of it in junior high school.
>
>Trig is not high-end math at all. You're right. But when it is taught, it is
>taught using degrees for the angles, never radians.

Rubbish. I was taught both.

>: OTOH, *all* the programming languages that I'm familiar with use radians
>: for the arguments of the trigonometric functions. So, I'm tempted to
>: believe that they're the standard in the computing industry. I'm also
>: tempted to believe that there must be a good reason for that.
>
>Most normal people never take up programming computers.

Did you call us abnormal? Outside you, now, and bring your bottle... !

>Working-class people
>who programme for amusement are about as rare as humans with full-scale fur
>coats.

Tell that to all the geeks working in the computer games industry...

Bloody Viking

unread,
Feb 25, 2001, 4:03:47 PM2/25/01
to

Lawrence Kirby (fr...@genesis.demon.co.uk) wrote:

: It is also very useful in many other areas of mathematics. Your observation


: is not entirely unrelated to the fact that in calculus the differential of
: sin(x) is cos(x), and the differential of cos(x) is -sin(x) when x is
: measured in radians. Basically if you are a mathematician doing anything
: nontrivial in this area you would be crazy to work with anything other
: than radians.

Removing conversion constants is always a good thing. Like the radians,
scientists prefer metric measurements over the "standard" of feet, inches,
pounds, etc. Oddly, in high school with a physics class, I came into it always
having done my calculations with the crappy English measurements and would
convert from metric to normal, do the math, and convert back. Yuck! If I tried
to just stay with metric, I'd get lost simply becuse as a Yank, metric is not
intuitive. So, I can safely say one reason Yanks suck at physics in general is
from our crappy measurement system.

About the only metric measures Yanks use are:

milligramme
gramme
kilogramme always pronounced as "key-low".

This came from prescription drugs (milligramme) and the illegal drug industry.
For physics and measure, America is a sad state of affairs. All 3 of the
metric measures Yanks use come from _drugs_.

The postal service, to be compliant with foreign postal systems, use kilos for
such mail, and we postal workers always call a kilogramme a kilo, just like
the illegal drug industry.

Speedometers often come with both mph and KMph, and barring a hotrodder
degaussing the mechanism part way to make the KMph scale show mph, it is
completely ignored.

Similarly, trig in America is always taught with degrees, not radians. Happily
for DIY programmers, converting degrees to radians is pretty easy, resulting
in software compatible with normal people. Someone could in theory code
physics software for the masses using the crappy normal measures.

: As far as programming languages go thre are a couple of points

: 2. If the language works in radians then the program it may have to provide


: conversions to othe scales on input and output. If the language works
: in something else the program may have to apply correction factors
: throughout its calculations. This is potentially much more significant
: than 1.

Maybe, maybe not. It'll depend on the exact problem. When I did the physics
class, I did my math in 3 steps:

Convert metric to normal.
Do the needed math.
Convert normal to metric.

In a trig proggie, it will work similarly, with a conversion to radians, the
needed math is done, and the output reconverted. Given the conversion
constant, this is trivial to add in. Trig in general is rather trivial, but
nice and useful.

Messing with vectors uses trig, so it is also trivial. For example, you have a
projectile that is aimed at a 45 degree angle and leaves the launcher at
100mph. Its vertical speed is 70.7mph and its horizontal speed is also
70.7mph. Knowing the vertical speed, it gets easy to calculate its flight
time, being twice that of the fall of an object with a terminal speed of
70.7mph. It will fly for 6.44 seconds, and knowing that, you can determine the
distance of the flight which is 668 feet. Quite a jump for a car!

A fun side note in computer history is that ballistics was why the ENIAC was
invented, to print up tables for artillery shells. The above ignores air
friction, but happily for large dense projectiles, air friction can be
ignored, at least for such projectiles at slow speeds. I also assumed both
ramps are equal height and ignored the car's attitude upon landing. Don't try
it! (: (certainly not without launching unmanned cars on that flight plan)

: I suspect that most spy satellites are in low orbit. You can see things


: in much more detail from a couple of hundred miles up than you can
: from 22000 miles.

That is exactly the case. A Russian spy satellite was recovered during the
1980s as its orbit decayed. The orbit decayed not according to plan, and the
sat came into our hands instead. Blame it on that pesky air friction. (: It
would be theoretically possible for an ordinary car to fly as a "lifting body"
if at the right attitude with sufficient speed. For an actual long range jump,
aerodynamics of a car would have to be taken into account, complicating the
math for the flight plan greatly. (and no, I don't work at The Skunk Works)

Mark McIntyre

unread,
Feb 25, 2001, 4:07:30 PM2/25/01
to
On Sun, 25 Feb 2001 17:37:27 +0000, "Edward Rosten" <lo...@my.sig>
wrote:

>>>That fun problem has the further challenge of taking into account the
>>>attitude of the car during ballistic flight. Air friction only adds more
>>>math fun! Use fins for attitude control for ballistic flight across the
>>>Grand Canyon.
>>
>> I think anyone willing to do that should be a nominee for a Darwin
>> award.
>
>Only if they remove themselves from the gene pool in the process.

Strictly they only need to prevent themselves passing on their genes.
I guess a close shave over the clifftop could also do that. *cringe*

Bloody Viking

unread,
Feb 25, 2001, 4:22:42 PM2/25/01
to

Ian Woods (new...@NOSPAMwuggy.co.uk) wrote:

: I think anyone willing to do that should be a nominee for a Darwin award.

Only if they kill themselves in the process. Evel Knievel came close to
getting one with the Snake River Canyon stunt. The intended flight plan was
ballistic up until around apogee and then a parachute would deploy and the
craft lands nose-down. As it happened, the chute deployed during launch,
almost putting him into the drink. Had it deployed a small fraction of a
second later, he would have ended up in the drink, and drowned. He would have
gotten his Darwin Award in that case.

As far as the theoretical car stunt, first one must code up a ballistics
programme to solve for distance. Next, the stuntman must calculate the pitch
nose-down to then mess with ramp angles to get it right. THEN he muse solve it
all with air friction added in with fins to hold the attitude in accord with
the mathematical flight plan. The second step is that of knowing the car's
centre of gravity and wheelbase. As the car leaves the ramp the front tyres
leave first and go into free fall while the back tyres are still supported by
the ramp. As speed increases the difference gets smaller that causes the
pitch, so it should be solvable.

Once you do the math to get a flight plan where the car lands on all fours on
the other ramp, it's then time to take into account the pesky air friction.

The fourth step is to launch an unmanned car (with weight to simulate a
driver) on the flight plan to ensure it works. Then, and only then, can he try
to avoid a Darwin Award while doing the stunt. It might be best to use the
guidance system as you man the car for the historic flight.

Ben Pfaff

unread,
Feb 25, 2001, 4:29:44 PM2/25/01
to
nos...@ripco.com (Bloody Viking) writes:

> Removing conversion constants is always a good thing. Like the radians,
> scientists prefer metric measurements over the "standard" of feet, inches,
> pounds, etc. Oddly, in high school with a physics class, I came into it always
> having done my calculations with the crappy English measurements and would
> convert from metric to normal, do the math, and convert back. Yuck! If I tried
> to just stay with metric, I'd get lost simply becuse as a Yank, metric is not
> intuitive. So, I can safely say one reason Yanks suck at physics in general is
> from our crappy measurement system.

If you have trouble with unit conversions, then do yourself a
favor and buy an HP 48G-series calculator. You can attach a unit
to any number and the calculator will automatically maintain
these units throughout a series of calculations. You can mix
English and metric units at will; the calculator understands
them. When you're done, you just tell it what units you want the
answer in, and hey presto! it converts it.

> About the only metric measures Yanks use are:
>
> milligramme
> gramme
> kilogramme always pronounced as "key-low".

You're forgetting about the liter (2-liter bottles of pop) and
the second, and perhaps some others that don't come to mind about
the moment.

> Similarly, trig in America is always taught with degrees, not radians.

Not where I was taught. Then again I took trigonometry here at
Michigan State University, not at a normal high school.

Joona I Palaste

unread,
Feb 25, 2001, 4:42:16 PM2/25/01
to
Ben Pfaff <pfaf...@msu.edu> scribbled the following
on comp.lang.c:
> nos...@ripco.com (Bloody Viking) writes:

>> Removing conversion constants is always a good thing. Like the radians,
>> scientists prefer metric measurements over the "standard" of feet, inches,
>> pounds, etc. Oddly, in high school with a physics class, I came into it always
>> having done my calculations with the crappy English measurements and would
>> convert from metric to normal, do the math, and convert back. Yuck! If I tried
>> to just stay with metric, I'd get lost simply becuse as a Yank, metric is not
>> intuitive. So, I can safely say one reason Yanks suck at physics in general is
>> from our crappy measurement system.

> If you have trouble with unit conversions, then do yourself a
> favor and buy an HP 48G-series calculator. You can attach a unit
> to any number and the calculator will automatically maintain
> these units throughout a series of calculations. You can mix
> English and metric units at will; the calculator understands
> them. When you're done, you just tell it what units you want the
> answer in, and hey presto! it converts it.

Ah yes, the HP 48G-series. When I was in high school, we were always
comparing our graphical calculators. I was (and still am) a fan of the
CASIO CFX series, while most of my schoolmates had TI-85 calculators.
The HP 48G(X) is otherwise nice, but there are some bad points:
1) The RPN system it uses is confusing.
2) It is very expensive compared to, for example, the CASIO CFX-9970G.
3) Because of its symbolic integration and derivation capabilities, it
is forbidden in the Finnish high school graduation exams.

>> About the only metric measures Yanks use are:
>>
>> milligramme
>> gramme
>> kilogramme always pronounced as "key-low".

> You're forgetting about the liter (2-liter bottles of pop) and
> the second, and perhaps some others that don't come to mind about
> the moment.

I think the second predates the metric system, so it doesn't count.
But I agree with Bloody Viking's point, the American measurement system
is obsolete. If they would only TRY the metric system they would get
to like it.

--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/

"It's not survival of the fattest, it's survival of the fittest."
- Ludvig von Drake

Edward Rosten

unread,
Feb 25, 2001, 7:00:42 PM2/25/01
to
> Ah yes, the HP 48G-series. When I was in high school, we were always
> comparing our graphical calculators. I was (and still am) a fan of the

I'm glad it wasn't just my class that did this. We would argue endlessly
aboyut them and write programs to prove which was better. The TI-85 had
better complex numbers and faster program exectuion, but the casio was
much faster at calculations and had some really useful list functions.

We generally used to write games. I wrote a breakout program on mine and
the old `valley of death' one.


> CASIO CFX series, while most of my schoolmates had TI-85 calculators.
> The HP 48G(X) is otherwise nice, but there are some bad points:
> 1) The RPN system it uses is confusing.
> 2) It is very expensive compared to, for example, the CASIO CFX-9970G.

I only hadf the 9850G (still have)

> 3) Because of its symbolic integration and derivation capabilities, it
> is forbidden in the Finnish high school graduation exams.

I think the TI-92 can do this now as well.

Aaron Kulkis

unread,
Feb 25, 2001, 11:10:34 PM2/25/01
to

Richard Heathfield wrote:
>
> Aaron Kulkis wrote:
> >
> > > Are you awared that the recommend maximum length for a .sig is 4 lines?
> > >
> >
> > Are you aware that this suggestion was formulated during the days
> > before fiber-optics, when MFM and RLL were not even invented yet,
> > and the ARPA-NET backbone had a 56k bandwidth and 20 megabyte disks
> > were considered huge...
>
> Are you aware that some of us are still using 28.8 modems and paying by
> the minute for our dialup connections, and that any saving is thus most
> welcome?

How much bandwidth do flamewars consume?

>
> If you answer, please remove your sig block before so doing.
>
> --
> Richard Heathfield
> "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
> C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
> K&R answers, C books, etc: http://users.powernet.co.uk/eton

--
Aaron R. Kulkis
Unix Systems Engineer
DNRC Minister of all I survey
ICQ # 3056642

L: "meow" is yet another anonymous coward who does nothing
but write stupid nonsense about his intellectual superiors.


K: Truth in advertising:
Left Wing Extremists Charles Schumer and Donna Shelala,
Black Seperatist Anti-Semite Louis Farrakan,
Special Interest Sierra Club,
Anarchist Members of the ACLU
Left Wing Corporate Extremist Ted Turner
The Drunken Woman Killer Ted Kennedy
Grass Roots Pro-Gun movement,


J: Other knee_jerk reactionaries: billh, david casey, redc1c4,
The retarded sisters: Raunchy (rauni) and Anencephielle (Enielle),
also known as old hags who've hit the wall....

I: Loren Petrich's 2-week stubborn refusal to respond to the
challenge to describe even one philosophical difference
between himself and the communists demonstrates that, in fact,
Loren Petrich is a COMMUNIST ***hole

H: "Having found not one single carbon monoxide leak on the entire
premises, it is my belief, and Willard concurs, that the reason
you folks feel listless and disoriented is simply because
you are lazy, stupid people"

G: Knackos...you're a retard.


F: Unit_4's "Kook hunt" reminds me of "Jimmy Baker's" harangues against
adultery while concurrently committing adultery with Tammy Hahn.

E: Jet is not worthy of the time to compose a response until
her behavior improves.

D: Jet Silverman now follows me from newgroup to newsgroup
...despite (C) above.

C: Jet Silverman claims to have killfiled me.

B: Jet Silverman plays the fool and spews out nonsense as a
method of sidetracking discussions which are headed in a
direction that she doesn't like.

A: The wise man is mocked by fools.

Aaron Kulkis

unread,
Feb 25, 2001, 11:11:20 PM2/25/01
to

Tim Hanson wrote:
>
> Aaron Kulkis wrote:
> >
> > Bloody Viking wrote:
> > >
> > > Edward Rosten (lo...@my.sig) wrote:
> > >
> > > : Those are perfectly normal errors: you have no cos function. You need to
> > > : link against the maths library as well as #including the header.
> > >
> > > : gcc -lm ...
> > >
> > > The "0lm" trick sure did it. Just tested it on another virtual console.
> > > Thanks! Fun easier quesation. Why isn't it in degrees as is the standard?
> > >
> >
> > Becuase Pi radians = 1 complete circle.
> >
>
> Nope. C = pi 2r = pi d.
>

You're right. My bad.


> > radians are a "unitless" type of unit, and therefore, the standard.
> >

> > > --
> > > FOOD FOR THOUGHT: 100 calories are used up in the course of a mile run.
> > > The USDA guidelines for dietary fibre is equal to one ounce of sawdust.
> > > The liver makes the vast majority of the cholesterol in your bloodstream.
> >

> --
> Vila: "I think I have just made the biggest mistake of my life."
> Orac: "It is unlikely. I would predict there are far greater mistakes
> waiting to be made by someone with your obvious talent for it."

Aaron Kulkis

unread,
Feb 25, 2001, 11:12:48 PM2/25/01
to

Joona I Palaste wrote:
>
> Aaron Kulkis <aku...@yahoo.com> scribbled the following
> on comp.lang.c:
>
> > Bloody Viking wrote:
> >>
> >> -hs- (email....@server.invalid) wrote:
> >>
> >> : To avoid the question "Why isn't it in radians as is the standard?"
> >>
> >> So, it is in radians. Now that I know about the "-lm" switch for the compile,
> >> I get to make a degree2radian conversion line to add to my code. Something
> >> off-topic is that the TI-86 calculator out of the box defaults to radians.
> >> (you set it to degrees)
> >>
> >> Here's a chance to correct (and flame) me. Last time I checked, a full circle
> >> is 3.1415926.... radians, that being pi number radians to equal 360 degrees.
> >> Time to add the conversion line to my little programme.
> >>
>
> > correct. Pi radians = one circle.
>
> Both of you are wrong. One circle equals 2*Pi radians.
>


You're right. circumference = 2 pi x r
I was thinking of pi x d.


> --
> /-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
> | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
> | http://www.helsinki.fi/~palaste W++ B OP+ |
> \----------------------------------------- Finland rules! ------------/
>

> "This is a personnel commuter."
> - Train driver in Scientific American

Aaron Kulkis

unread,
Feb 25, 2001, 11:21:42 PM2/25/01
to

Edward Rosten wrote:
>
> In article <979rsq$c3s$1...@sunnews.cern.ch>, "Dan Pop" <Dan...@cern.ch>
> wrote:
>

> > In <979mmq$i3t$1...@news.ox.ac.uk> "Edward Rosten" <lo...@my.sig> writes:
> >
> >>> There are 2 pi radians in a full circle, so the conversion is pi /
> >>> 180.0:
> >>>
> >>> double deg_to_rad(double degrees)
> >>> {
> >>> return degrees * 3.14159265358979323846 / 180.0;
> >>> }
> >>
> >>It would be easier to use M_PIl as #defined in math.h
> >

> > <math.h> has no licence to define such a macro when the compiler is
> > invoked in conforming mode.
>

> Is there an official place where a definition of PI is meant to reside?
>

/usr/include/math.h

he was talking saying that a macro to implement the function listed
above doesn't belone in math.h

> -Ed
>
> --
> | u98ejr
> | @
> Share, and enjoy. | eng.ox
> | .ac.uk

--

Aaron Kulkis

unread,
Feb 26, 2001, 12:28:30 AM2/26/01
to

mlw wrote:
>
> Lawrence Kirby wrote:
> >
> > In article <3A980D6F...@eton.powernet.co.uk>
> > bin...@eton.powernet.co.uk "Richard Heathfield" writes:
> >
> > ...
> >
> > >Not just yet! :-)
> > >
> > >There are 2 pi radians in a full circle, so the conversion is pi /
> > >180.0:
> > >
> > >double deg_to_rad(double degrees)
> > >{
> > > return degrees * 3.14159265358979323846 / 180.0;
> >
> > Although I'd prefer to write that as
> >
> > return degrees * (3.14159265358979323846 / 180.0);
> >
> > There's no point in forcing unnecessary runtime divisions.
>
> Actually, you should do it this way:
>
> return (degrees * 3.14159265358979323846) / 180.0;
>
> This will preserve more precision.

Only if using fixed-point notation.

With floating point, it's the same loss of accuracy either way.


>
> --
> The majority of the stupid is invincible and guaranteed for all time.
> The terror of their tyranny, however, is alleviated by their lack of
> consistency.
> -- Albert Einstein
> ------------------------
> http://www.mohawksoft.com

--

Aaron Kulkis

unread,
Feb 26, 2001, 12:29:15 AM2/26/01
to

Topology doesn't generally deal in silly things like group theory.


>
> -Chris

Allin Cottrell

unread,
Feb 26, 2001, 12:23:53 AM2/26/01
to
Aaron Kulkis quoted Richard Heathfield:

> > If you answer, please remove your sig block before so doing.

Richard, you have to understand that Mr Kulkis is a Free American
Citizen, and as such has a God-given Right to do whatever the
hell he likes (e.g. appending 1708 bytes of yahoo rant to all
his Usenet postings), however annoying and inconvenient it may
be for the rest of us.

Allin Cottrell

It is loading more messages.
0 new messages