[Main]
Title=I need the C equivalent of the when() function from TI-Basic.

[Top]
<TABLE CELLPADDING="4"><TR><TD VALIGN="TOP"><B>Q:</B></TD><TD>
I need the C equivalent of the <CODE>'when()'</CODE> function from TI-Basic.
</TD></TR><TR><TD VALIGN="TOP"><B>A:</B></TD><TD>
This is simple:
<PRE>when (<I>condition</I>, <I>true_val</I>, <I>false_val</I>)
</PRE>
is translated to C as
<PRE><I>condition</I> ? <I>true_val</I> : <I>false_val</I>
</PRE>
For example,
<PRE>sign = x &gt;= 0 ? 1 : -1;
</PRE>
Happy?
</TD></TR></TABLE>
