Bool - with AM and PM

May 16, 2017 at 9:14pm
Hi Guys :)

I am running an example from book and something is puzzling me. I don't understand why code behaves in such way:

 
bool pm = hours < 12 ? false : true; // find am/pm  


I have entered hours as 22, after executing of this line pm flag is changed to TRUE in debugger.

My understanding (well I don't understand the line exactly I think this is the issue)
is as far

choice bool (true or false) PM will be true if hours is smaller then 12, or false when is bigger then 12.

But it appears its the opposite.

where I could read about this < 12 ? false : true; or if someone have time to explain how to read/understand this syntax I would much appreciate :)

thank you :)
May 16, 2017 at 9:33pm
May 16, 2017 at 9:44pm
Keskiverto - thank you!!

That was one excellent explanation.

why I am not correct in reading that if hours is less then 12 it should be false??? :D

hours = 22
PM (hours) is bigger then 12 so it should be read as False????
May 16, 2017 at 10:25pm
Topic archived. No new replies allowed.