TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KURT J. TISCHER
from: CAMERON CLARK
date: 1997-07-10 03:16:00
subject: Re: Signs of numbers

KJ>        Does Visual C++ have a similar function?  If so, in what header 
file
KJ> is it located and what is the name of the function?  If not, would 
omeone
KJ> please show me a function to determine the sign of a number which would
KJ> return 1 if positive, 0 if zero, and -1 if negative...?
    The first bit of a number signifies the sign of a number
    so
    char c = (some number);
    negative = (c & 0x80);
    zero = (c & (-1));
    positive = !negative;
   
    1000 0000 is 0x80
    -1 = all ones  1111 1111
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.