On Thu, 20 Mar 2014 11:51:34 -0700, Jim Thompson wrote:
Anyone know how to interpret this IF (I think) statement...
PMI=(PM=0)?((PM==0)?1000:PM):PMC
it's in a notation-style I don't understand.
It looks like C-style conditional operator (whose use is frowned upon,
particularly in cascade like that).
In C and C++,
ANSWER = THING ? THIS : THAT;
means that if THING is true, ANSWER = THIS. Of THING is false, ANSWER =
THAT.
In more traditional if-else notation, your statement expands to:
if (PM = 0)
{
if (PM == 0)
{
PMI = 1000;
}
else
{
PMI = PM;
}
}
else
{
PMI = PMC;
}
Which packs much less confusion per line, and is therefor much less
desirable from a geeky programmer point of view.
Those limp-wristed busybodies at MISRA have ruled out its use in mission-
critical software, if you can imagine that.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com