←back to thread

420 points gnabgib | 1 comments | | HN request time: 0.203s | source
Show context
captaincrunch ◴[] No.44000123[source]
This is fast, READABLE, and accurate:

bool is_leap_year(uint32_t y) { // Works for Gregorian years in range [0, 65535] return ((!(y & 3)) && ((y % 25 != 0) || !(y & 15))); }

replies(3): >>44000304 #>>44000522 #>>44003153 #
kragen ◴[] No.44000522[source]
You commented out your entire function body and the closing }. Also, on 32-bit platforms, it doesn't stop working at 65535.
replies(1): >>44001008 #
captaincrunch ◴[] No.44001008[source]
just a formatting issue on my side, there were \n.
replies(2): >>44003548 #>>44007925 #
1. archargelod ◴[] No.44003548[source]
This website eats newlines, unless you double them (one of the annoying features of markdown). You can use codeblocks by putting 4 spaces before each line:

    int main() {
        // this should be properly formatted
        return 0;
    };