{"id":41,"date":"2018-05-04T08:16:27","date_gmt":"2018-05-04T06:16:27","guid":{"rendered":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/?p=41"},"modified":"2018-05-04T08:16:27","modified_gmt":"2018-05-04T06:16:27","slug":"uebung-4-5","status":"publish","type":"post","link":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/2018\/05\/uebung-4-5\/","title":{"rendered":"\u00dcbung 4.5."},"content":{"rendered":"<pre>\r\n\r\n#include \r\n\r\nchar *int2bin(int n) {\r\n        \/\/ determine the number of bits needed (\"sizeof\" returns bytes)\r\n        int nbits = sizeof(n) * 8;\r\n        char *s = malloc(nbits+1);  \/\/ +1 for '\\0' terminator\r\n        s[nbits] = '\\0';\r\n        \/\/ forcing evaluation as an unsigned value prevents complications\r\n        \/\/ with negative numbers at the left-most bit\r\n        unsigned int u = *(unsigned int*)&amp;n;\r\n        int i;\r\n        unsigned int mask = 1 &lt;&lt; (nbits-1); \/\/ fill in values right-to-left\r\n        for (i = 0; i &gt;= 1)\r\n            s[i] = ((u &amp; mask) != 0) + '0';\r\n        return s;\r\n    }\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include char *int2bin(int n) { \/\/ determine the number of bits needed (&#8222;sizeof&#8220; returns bytes) int nbits = sizeof(n) * 8; char *s = malloc(nbits+1); \/\/ +1 for &#8218;\\0&#8216; terminator s[nbits] = &#8218;\\0&#8216;; \/\/ forcing evaluation as an unsigned value prevents complications \/\/ with negative numbers at the left-most bit unsigned int u = *(unsigned [&hellip;]<\/p>\n","protected":false},"author":3370,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/posts\/41"}],"collection":[{"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/users\/3370"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":2,"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":43,"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/posts\/41\/revisions\/43"}],"wp:attachment":[{"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.urz.uni-halle.de\/cuebung\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}