{"id":19902,"date":"2023-01-19T06:17:45","date_gmt":"2023-01-19T06:17:45","guid":{"rendered":"https:\/\/www.booksofall.com\/tw\/?post_type=product&#038;p=19902"},"modified":"2023-01-19T06:19:28","modified_gmt":"2023-01-19T06:19:28","slug":"matters-computational-ideas-algorithms-source-code","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/","title":{"rendered":"Matters Computational &#8211; Ideas, Algorithms, Source Code"},"content":{"rendered":"<h2>Bit wizardry<\/h2>\n<p>We give low-level functions for <a href=\"https:\/\/byjus.com\/maths\/binary-number-system\/\">binary words<\/a>, such as isolation of the lowest set bit or counting all set bits. Sometimes the term \u2018one\u2019 is used for a set bit and \u2018zero\u2019 for an unset bit. Where it cannot cause confusion, the term \u2018bit\u2019 is used for a set bit (as in \u201ccounting the bits of a word\u201d).<\/p>\n<p>The<a href=\"https:\/\/www.tutorialspoint.com\/cprogramming\/c_data_types.htm\"> C-type<\/a> unsigned long is abbreviated as ulong as defined in [FXT: fxttypes.h]. It is assumed that BITS_PER_LONG reflects the size of an unsigned long. It is defined in [FXT: bits\/bitsperlong.h] and usually equals the machine word size: 32 on 32-bit architectures, and 64 on 64-bit machines. Further, the quantity BYTES_PER_LONG reflects the number of bytes in a machine word: it equals BITS_PER_LONG divided by eight. For some functions it is assumed that long and ulong have the same number of bits.<\/p>\n<p>Many functions will only work on machines that use two\u2019s complement, which is used by all of the current general purpose computers (the only machines using one\u2019s complement appear to be some successors of the <a href=\"https:\/\/www.history.com\/this-day-in-history\/univac-computer-dedicated\">UNIVAC system<\/a>, see [358, entry \u201cUNIVAC 1100\/2200 series\u201d]).<\/p>\n<p>The examples of assembler code are for the x86 and the AMD64 architecture. They should be simple enough to be understood by readers who know assembler for any CPU.<\/p>\n<h3>Trivia<\/h3>\n<p><a href=\"https:\/\/chortle.ccsu.edu\/assemblytutorial\/Chapter-15\/ass15_3.html\"><strong>Little endian versus big endian<\/strong><\/a><\/p>\n<p>The order in which the bytes of an integer are stored in memory can start with the least significant byte (little endian machine) or with the most significant byte (big endian machine). The hexadecimal number 0x0D0C0B0A will be stored in the following manner if memory addresses grow from left to right:<\/p>\n<p>adr: z z+1 z+2 z+3<br \/>\nmem: 0D 0C 0B 0A \/\/ big endian<br \/>\nmem: 0A 0B 0C 0D \/\/ little endian<\/p>\n<p>The difference becomes visible when you cast pointers. Let V be the 32-bit integer with the value above. Then the result of char c = *(char *)(&amp;V); will be 0x0A (value modulo 256) on a little endian machine but 0x0D (value divided by 224) on a big endian machine. Though friends of big endian sometimes refer to little endian as \u2018wrong endian\u2019, the desired result of the shown pointer cast is much more often the modulo operation.<\/p>\n<p>Whenever words are serialized into bytes, as with transfer over a network or to a disk, one will need two code versions, one for big endian and one for little endian machines. The C-type union (with words and bytes) may also require separate treatment for big and little endian architectures.<\/p>\n<p><strong>Size of pointer is not size of int<\/strong><\/p>\n<p>If programming for a <a href=\"https:\/\/www.computerhope.com\/jargon\/num\/32bit.htm\">32-bit<\/a> architecture (where the size of int and long coincide), casting pointers to integers (and back) will usually work. The same code will fail on 64-bit machines. If you have to cast pointers to an integer type, cast them to a sufficiently big type. For portable code it is better to avoid casting pointers to integer types.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/matters-computational-ideas-algorithms-source-code-185w5kzl6j?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":19909,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!"},"product_brand":[],"product_cat":[263],"product_tag":[],"class_list":{"0":"post-19902","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-algorithms-data-structures","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Matters Computational - Ideas, Algorithms, Source Code - BooksOfAll Traditional Chinese<\/title>\n<meta name=\"description\" content=\"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Matters Computational - Ideas, Algorithms, Source Code - BooksOfAll Traditional Chinese\" \/>\n<meta property=\"og:description\" content=\"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll Traditional Chinese\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-19T06:19:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/\",\"url\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/\",\"name\":\"Matters Computational - Ideas, Algorithms, Source Code - BooksOfAll Traditional Chinese\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg\",\"datePublished\":\"2023-01-19T06:17:45+00:00\",\"dateModified\":\"2023-01-19T06:19:28+00:00\",\"description\":\"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg\",\"width\":\"827\",\"height\":\"1169\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/tw\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/tw\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Matters Computational &#8211; Ideas, Algorithms, Source Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/#website\",\"url\":\"https:\/\/www.booksofall.com\/tw\/\",\"name\":\"BooksOfAll Traditional Chinese\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/tw\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/#organization\",\"name\":\"BooksOfAll Traditional Chinese\",\"url\":\"https:\/\/www.booksofall.com\/tw\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll Traditional Chinese\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Matters Computational - Ideas, Algorithms, Source Code - BooksOfAll Traditional Chinese","description":"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/","og_locale":"zh_TW","og_type":"article","og_title":"Matters Computational - Ideas, Algorithms, Source Code - BooksOfAll Traditional Chinese","og_description":"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!","og_url":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/","og_site_name":"BooksOfAll Traditional Chinese","article_modified_time":"2023-01-19T06:19:28+00:00","og_image":[{"url":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg","twitter_misc":{"\u9810\u4f30\u95b1\u8b80\u6642\u9593":"2 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/","url":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/","name":"Matters Computational - Ideas, Algorithms, Source Code - BooksOfAll Traditional Chinese","isPartOf":{"@id":"https:\/\/www.booksofall.com\/tw\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg","datePublished":"2023-01-19T06:17:45+00:00","dateModified":"2023-01-19T06:19:28+00:00","description":"There are different algorithms that usually include different examples of calculations, learn more about the actual performance of different programs!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/"]}]},{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#primaryimage","url":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg","contentUrl":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/01\/cover-Page-13-1.jpg","width":"827","height":"1169"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/tw\/matters-computational-ideas-algorithms-source-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/tw\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/tw\/categories\/"},{"@type":"ListItem","position":3,"name":"Matters Computational &#8211; Ideas, Algorithms, Source Code"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/tw\/#website","url":"https:\/\/www.booksofall.com\/tw\/","name":"BooksOfAll Traditional Chinese","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/tw\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/tw\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/tw\/#organization","name":"BooksOfAll Traditional Chinese","url":"https:\/\/www.booksofall.com\/tw\/","logo":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll Traditional Chinese"},"image":{"@id":"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product\/19902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/media\/19909"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/media?parent=19902"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product_brand?post=19902"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product_cat?post=19902"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product_tag?post=19902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}