![]() |
|
best way to handle the 24 hr time format? - Printable Version +- kanji koohii FORUM (http://forum.koohii.com) +-- Forum: Learning Japanese (http://forum.koohii.com/forum-4.html) +--- Forum: General discussion (http://forum.koohii.com/forum-8.html) +--- Thread: best way to handle the 24 hr time format? (/thread-4690.html) Pages:
1
2
|
best way to handle the 24 hr time format? - jajaaan - 2009-12-27 I always found that subtracting 12 was too cumbersome. It's an extra step in what is already a one-step process. The only reason a 12-hour clock means anything to your brain is because you associate certain times with meaningful events. 7:30am is breakfast, 12:00pm is lunch, 5:00pm is when you get off work, 11:00 is when you go to bed, etc. So just take a handful of meaningful events that happen after noon and re-assign the times. 15:00 schools let out 17:00 people get off work 19:00 prime time TV shows air 23:00 time to go to sleep best way to handle the 24 hr time format? - Daichi - 2009-12-28 dizmox Wrote:You both realize that C also has the modulus operator?unauthorized Wrote:Or you could do it in C:I'll cheat and use Matlab. Code: hour % 12Personally, I've always used the subtract two method in my head. best way to handle the 24 hr time format? - dizmox - 2009-12-28 My mistake, then. D: best way to handle the 24 hr time format? - unauthorized - 2009-12-28 pm215 Wrote:(waaay off topic, but) *blink*. If you want to make the program exit on malloc failure then wrap malloc. If you don't check you don't get a crash, you get undefined behaviour, and you never want that. (If you're really unlucky you get undefined behaviour which is a security hole.)Actually, any attempt to reference data by a NULL pointer would be caught by the CRT as per the standard specifications. This is one of the few security features in C. @Daichi, dizmox: I thought it was bluntly obvious that I was trying to use the most pointlessly long way to do it. Why else would I use C? best way to handle the 24 hr time format? - pm215 - 2009-12-28 unauthorized Wrote:Actually, any attempt to reference data by a NULL pointer would be caught by the CRT as per the standard specifications. This is one of the few security features in C.The C standard disagrees with you: C99 standard section 6.5.3.2 paragraph 4 Wrote:The unary * operator denotes indirection. [...] If an C99 footnote 90 Wrote:Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime.Just because most C runtimes happen to make NULL pointer dereferences crash doesn't mean they are obliged to by the standard. In an embedded environment it's quite plausible that they will not be caught but instead you'll just scribble on low memory. The implementation is entirely at liberty to start nethack or cause demons to fly out of your nose or anything else it feels like. It's not a good idea to ignore malloc returns on platforms which do fault on accesses to NULL either -- Mark Dowd's neat Flash player exploit gets its starting point from a memory allocation call that some programmer in Adobe forgot to check for failure. best way to handle the 24 hr time format? - unauthorized - 2009-12-28 pm215 Wrote:The C standard disagrees with you:I wasn't aware of that. Thanks for bringing it to my attention. pm215 Wrote:The implementation is entirely at liberty to start nethack or cause demons to fly out of your nose or anything else it feels like.So THIS is where the little suckers came from! For a moment, I was worried. best way to handle the 24 hr time format? - dizmox - 2009-12-28 Quote:@Daichi, dizmox: I thought it was bluntly obvious that I was trying to use the most pointlessly long way to do it. Why else would I use C?Yeah, I did, but I didn't know there was a modulus function. I gave up on C halfway through some beginner's tutorial.
|