On 08-Jul-97, Kurt J. Tischer wrote to All about Signs of numbers.
KJT> is it located and what is the name of the function? If not, would
KJT> someone
KJT> please show me a function to determine the sign of a number which would
KJT> return 1 if positive, 0 if zero, and -1 if negative...?
// You'd maybe like to template this f()
int foo(int num)
{
if (num) {
if (num > 0) {
return 1;
} else {
return -1;
}
} else {
return 0;
}
}
Or a HD saver version:
int foo(int num) { return num ? (num > 0 ? 1 : -1) : 0; }
Internet: jkohen@tough.com þ Javier Kohen/The_Crusher þ
ttp://jkohen.base.org
Fidonet: 4:900/748.3 þ Sk-Network: 200:201/126 þ Rockernet: 33:300/100.3
PGP keyID: 3423EAA9
... No, Taco Bell is *not* the Mexican telephone company!
-!- CrusherTag 0.3.2.
--- Terminate 4.00/Pro
4:900/748.3)
---------------
* Origin: The King of The Ring BBS þ +54-1-OFF-LINE þ TLD 0 - 7
|