A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
A simple question
Joined: Nov 25, 2004
Dec 09, 2004 09:02:00
Hi,could you please let me know what the following ststement says:
theDX = theDX > MAX_V ? MAX_V : theDX;
[ December 09, 2004: Message edited by: Ernest Friedman-Hill ]
author and iconoclast
Joined: Jul 08, 2003
Dec 09, 2004 09:06:00
I edited your post to remove some superfluous formatting.
The ? and : characters together are the "ternary operator." It's basically a shorthand way of writing "if/then". Another way to write exactly the same thing would be
if (theDX > MAX_V) theDX = MAX_V else theDX = theDX;
Of course, written out like this, the "else" part is redundant.
[Jess in Action]
I agree. Here's the link:
subject: A simple question
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013