Wow, so many differnt ways heh, thanks everyone =)
Michael Barton wrote:
Or:
variable = -variable;
takes less cpu than multiplying by -1.
If you use abs, you'll also have to add -lm to the L_FLAGS in your
makefile (to link to the math library).
Or you could just write your own...
int my_abs(int a)
{
return (a < 0) ? -a : a;
}
On 4/16/05, Ammaross Danan <[EMAIL PROTECTED]> wrote:
Number * -1
Or
#include <math.h>
Number = abs(Number);
Use the later if you always want it to be positive, the first could
potentially make it go negative if it was positive to begin with...
Ammaross
www.rotf.net
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of cyhawk
Sent: Saturday, April 16, 2005 1:54 PM
To: [email protected]
Subject: Quick question on math in C
Err how would i convert a negitive number to a positive number?
ie -5 to 5
or -754 to 754
in c?
Google was no help cause i have no idea how to form the question ;) Thanks
=)
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
On 4/16/05, Ammaross Danan <[EMAIL PROTECTED]> wrote:
Number * -1
Or
#include <math.h>
Number = abs(Number);
Use the later if you always want it to be positive, the first could
potentially make it go negative if it was positive to begin with...
Ammaross
www.rotf.net
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of cyhawk
Sent: Saturday, April 16, 2005 1:54 PM
To: [email protected]
Subject: Quick question on math in C
Err how would i convert a negitive number to a positive number?
ie -5 to 5
or -754 to 754
in c?
Google was no help cause i have no idea how to form the question ;) Thanks
=)
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom