http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some trig trouble -- and IEEE floating point format



sind() is in <math.h>
the man page for sind on my school's unix server says 'named in accordance
with the conventions specified in the "Future Library Directions" section of
the ANSI C standard.'
and its dated 1997, so i would assume its a standard function of the math
lib, but that might be a dangerous assumption.

as far as typecasting goes...think of it like this: if you try to give
someone a pile of crap (literally), you have no chance in hell at getting
rid of it. but put that crap in a green bag and call it 'fertilizer', people
will be more than happy to take it off your hands. get it? nomen est omen.

--Bill

----- Original Message -----
From: "Lionel Pinkhard" <lionelp@worldonline.co.za>
To: <gameprogrammer@gameprogrammer.com>
Sent: Tuesday, September 05, 2000 9:43 PM
Subject: Re: Some trig trouble -- and IEEE floating point format


> Hi,
>
> Well, angle_deg was set to 60.0, but I solved the problem, I don't know
> how, but I just recompiled the code and it worked. But I tried using that
> sind() function, and I couldn't get it working, which header file needs to
> be included?
>
> And what exactly is a 'cast'?
>
> One more thing: Does somebody know of a simple method (under Dos) to input
> from the keyboard? Except using a kbhit()/getch() combo, since that seems
> to be too slow in my situation. Is it possible to input directly from port
> 0x60? And manually clear the buffer, etc. (Well, I'm pretty sure it's
> possible, 'cause Dos can do it :-) ) If so, how?
>
> Ciao,
>
> Lionel
>
> P.s. Does anybody know of any source code for a mouse driver? I'm working
> on an operating system, and I would really like to add some mouse support.
>
> On Tue, 5 Sep 2000, slick willy wrote:
>
> > unless your angle_deg is not a double, then i dont see a problem with
the
> > code. however, you could always try sind(double x) or sindf(float x)
which
> > both take an angle in degrees as their argument.
> >
> > --Bill
> >
> > ----- Original Message -----
> > From: "Lionel Pinkhard" <lionelp@worldonline.co.za>
> > To: <gameprogrammer@gameprogrammer.com>
> > Sent: Tuesday, September 05, 2000 3:31 PM
> > Subject: Some trig trouble -- and IEEE floating point format
> >
> >
> > > Hey guys/gals,
> > >
> > > I got some trouble with a simple procedure to convert degrees into
> > > radians, and then calculate the sine of the angle, here's my code
(with a
> > > 'printf' for diagnostics -- value is in angle_deg):
> > >
> > > double angle_rad, sine;
> > >
> > > angle_rad = angle_deg * M_PI / 180.0;
> > > sine = sin(angle_rad);
> > >
> > > printf("The sine of %.2f is %.8f.\r\n", angle_deg, sine);
> > >
> > > If I try to run this code, I get "Floating point error: Domain.",
> > > "Abnormal program termination". What am I doing wrong? I have an idea
it's
> > > something really simple.
> > >
> > > Next, a little problem with pointers:
> > >
> > > I'm using pointers to return the movement from the joystick:
> > >
> > > Function:
> > > void joy_movement(signed char *x, signed char *y) {
> > >     unsigned short absx, absy;
> > >     signed char deltax, deltay;
> > >
> > >     joy_absolute(&absx, &absy);
> > >
> > >     << rest of code here >>
> > >
> > >     *x = deltax;
> > >     *y = deltay;
> > > }
> > >
> > > Program:
> > >     joy_movement(&x, &y);
> > >
> > > joy_movement is a function to get the movement from the joystick in
the
> > > range -127 to 128 (that's why I'm using a char). joy_absolute is a
> > > function to return the axises of the joystick, and is in the same
format
> > > as joy_movement. When I compile I get the 'unportable pointer'
messages,
> > > and the functions don't work.
> > >
> > > Hope somebody can help me out here!
> > >
> > > Nextly, somebody asked about floating point numbers, well for
> > > single-precision (4 bytes), the sign takes 1 bit, the exponent takes 8
> > bits and
> > > the mantissa uses the other 23 bits (the number is 32-bit). For
> > > double-precision (8 bytes), the sign takes 1 bit, the exponent takes
11
> > > bits and the mantissa uses the other 52 bits (the number is 64-bit).
I'm
> > > not sure about how correct this is, but try printing out a float in
> > > hexadecimal or something (I'm not sure whether that is possible, can
> > > somebody help me out there?) Anyways, this is the IEEE format, there
are
> > > also other formats, such as Microsoft's format, but I think that's
> > > obsolete by now.
> > >
> > > Ciao,
> > >
> > > Lionel
> > >
> > > =================================================================
> > > The GameProgrammer.Com mailing list is for the open discussion
> > > of any topic related to the art, science, and business of
> > > programming games. This list is especially tolerant of beginners.
> > > We were all beginners once
> > >
> > > To SUBSCRIBE or UNSUBSCRIBE please visit:
> > > http://gameprogrammer.com/mailinglist.html
> > >
> > >
> >
> > =================================================================
> > The GameProgrammer.Com mailing list is for the open discussion
> > of any topic related to the art, science, and business of
> > programming games. This list is especially tolerant of beginners.
> > We were all beginners once
> >
> > To SUBSCRIBE or UNSUBSCRIBE please visit:
> > http://gameprogrammer.com/mailinglist.html
> >
>
> =================================================================
> The GameProgrammer.Com mailing list is for the open discussion
> of any topic related to the art, science, and business of
> programming games. This list is especially tolerant of beginners.
> We were all beginners once
>
> To SUBSCRIBE or UNSUBSCRIBE please visit:
> http://gameprogrammer.com/mailinglist.html
>
>

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html