hi,
im converting a program and can't understand a statement please can
you help
this is the statement
double s_star = (s_star_raw > s0) ? s_star_raw : s0;
so ok.. .if
s_star_raw = 15
s0 = 3
what is s_star?
thank you for helping.
Jeff Higgins - 19 Mar 2007 03:56 GMT
> hi,
> im converting a program and can't understand a statement please can
[quoted text clipped - 12 lines]
>
> thank you for helping.
if s_star_raw is greater than s0 then s_star equals s_star_raw otherwise
s_star equals s0
Jeff Higgins - 19 Mar 2007 04:26 GMT
>> hi,
>> im converting a program and can't understand a statement please can
[quoted text clipped - 15 lines]
> if s_star_raw is greater than s0 then s_star equals s_star_raw otherwise
> s_star equals s0
also see Conditional Operator (?:)
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25
Tom Hawtin - 19 Mar 2007 05:22 GMT
> if s_star_raw is greater than s0 then s_star equals s_star_raw otherwise
> s_star equals s0
Or to put it more sensibly:
double sStar = Math.max(sStarRaw, s0);
Tom Hawtin
Sherm Pendley - 19 Mar 2007 05:30 GMT
> im converting a program and can't understand a statement please can
> you help
>
> this is the statement
>
> double s_star = (s_star_raw > s0) ? s_star_raw : s0;
The expression "(test) ? true_value : false_value" evaluates to true_value
if test is true, or false_value if not.
In other words, the above is equivalent to this:
double s_star;
if (s_star_raw > s0) {
s_star = s_star_raw;
} else {
s_star = s0;
}
sherm--

Signature
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Ian Shef - 18 Apr 2007 20:40 GMT
"Moham12345" <m_w_raza@hotmail.com> wrote in news:1174272582.727537.164780
@y80g2000hsf.googlegroups.com:
> hi,
> im converting a program and can't understand a statement please can
[quoted text clipped - 12 lines]
>
> thank you for helping.
I could give you the answer, but then what would you learn? Here is a
clue.
The expression
a?b:c
provides a value of "b" if "a" is true, otherwise it provides a value of
"c".
(The double quotes I used are meant as separators and not as indicators of
a String).
This should be enough of a clue to figure it out. If not, then you had
better back up and study Java some more.
Good Luck!

Signature
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *