TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PETER HAYWOOD
from: MATHIEU BOUCHARD
date: 1997-08-16 02:46:00
subject: Re: Signs of numbers

 PH> int s, i;
 PH> i = -647;       /* set i to some value */
 PH> s = (i =0 */
 PH>   You could even define a simple macro to perform the same task as
 PH> your VB function:
by the way this SGN is afaik standard in all versions of BASIC or at
least TRS-80 Color Basic, GWBASIC, QuickBASIC, PowerBASIC, and most
others.
 PH> #define Sgn(x) (x  0 ? 1 : 0)
i would recommend a non-macro one, that avoids nasty side effects,
enforces type-checking, and clears out most nameconflicts:
template  inline int sgn (Any x) { return x0; }
matju
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)

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™.