{"id":183,"date":"2011-06-14T10:13:32","date_gmt":"2011-06-14T09:13:32","guid":{"rendered":"http:\/\/www.andreazin.it\/solutions\/?p=183"},"modified":"2011-06-14T10:52:11","modified_gmt":"2011-06-14T09:52:11","slug":"shift-right-zero-fill-c-net-porting","status":"publish","type":"post","link":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html","title":{"rendered":">>> Shift right zero fill &#8211; C#.Net porting"},"content":{"rendered":"<p><span style=\"font-size: small; font-family: verdana, geneva;\">Ho passato un po&#8217; di tempo a cercare in .Net una soluzione per tradurre l&#8217;operatore &gt;&gt;&gt; usato in javascript.<br \/>\nNon l&#8217;ho trovata.<\/span><\/p>\n<p><span style=\"font-size: small;\"><span style=\"font-family: verdana, geneva;\">Allora mi sono scritto una piccola funzione che fa la stessa cosa ma deve essere modificata se la variabile \u00e8 un Int32 oppure un Int64. Preferibilmente utilizzerei UInt32 \/ UInt64.<br \/>\nLa modifica da fare \u00e8 cambiare la costante 32 o 64.<\/span><\/span><\/p>\n<p><span style=\"font-size: small;\"><span style=\"font-family: verdana, geneva;\">La funzione &#8220;<strong>Shift right zero fill<\/strong>&#8221; a differenza dello shift right comune ( <strong>&gt;&gt;<\/strong> ), aggiunge 0 a destra del numero binario. Anche <strong>&gt;&gt;<\/strong> aggiunge 0 ma solo se il numero \u00e8 positivo&#8230;<\/span><\/span><\/p>\n<p><span style=\"font-size: small;\"><span style=\"font-family: verdana, geneva;\">Questa funzione non fa altro che :<\/span><\/span><\/p>\n<ul>\n<li><span style=\"font-size: small;\"><span style=\"font-family: verdana, geneva;\">Fare il right bit shift comune ( <strong>&gt;&gt;<\/strong> )<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\"><span style=\"font-family: verdana, geneva;\">Comporre una maschera di bit con tanti zero a dx quanti sono i bit shiftati e il resto della maschera a 1, e poi fare un AND logico.<\/span><\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: small;\"><span style=\"font-family: verdana, geneva;\">la funzione \u00e8 la seguente:<\/span><\/span><\/p>\n<pre class=\"brush:csharp\">        private UInt32 shiftrZeroFill(UInt32 number, Int32 bits) {\r\n            UInt32 p = UInt32.MaxValue;\r\n            UInt32 r = ~((p &gt;&gt;= (32 - bits)) &lt;&lt; (32 - bits));\r\n            return (number &gt;&gt; bits) &amp; r;\r\n        }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>>>> Shift Right Zero Fill in C# <a href=\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\">Continua a leggere<span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[21],"tags":[42,73,31,41,40],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-net","tag-42","tag-net","tag-c","tag-javascript","tag-shift-right-zero-fill"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>&gt;&gt;&gt; Shift right zero fill - C#.Net porting - Note book<\/title>\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.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"&gt;&gt;&gt; Shift right zero fill - C#.Net porting - Note book\" \/>\n<meta property=\"og:description\" content=\"&gt;&gt;&gt; Shift Right Zero Fill in C# Continua a leggere&rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\" \/>\n<meta property=\"og:site_name\" content=\"Note book\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-14T09:13:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-06-14T09:52:11+00:00\" \/>\n<meta name=\"author\" content=\"Andrea\" \/>\n<meta name=\"twitter:label1\" content=\"Scritto da\" \/>\n\t<meta name=\"twitter:data1\" content=\"Andrea\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\"},\"author\":{\"name\":\"Andrea\",\"@id\":\"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/e47a2b851307c3b969373910264a37ef\"},\"headline\":\">>> Shift right zero fill &#8211; C#.Net porting\",\"datePublished\":\"2011-06-14T09:13:32+00:00\",\"dateModified\":\"2011-06-14T09:52:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\"},\"wordCount\":145,\"commentCount\":0,\"keywords\":[\"&gt;&gt;&gt;\",\".Net\",\"C#\",\"Javascript\",\"Shift Right Zero Fill\"],\"articleSection\":[\".Net\"],\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\",\"url\":\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\",\"name\":\">>> Shift right zero fill - C#.Net porting - Note book\",\"isPartOf\":{\"@id\":\"https:\/\/www.andreazin.it\/solutions\/#website\"},\"datePublished\":\"2011-06-14T09:13:32+00:00\",\"dateModified\":\"2011-06-14T09:52:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/e47a2b851307c3b969373910264a37ef\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.andreazin.it\/solutions\/#website\",\"url\":\"https:\/\/www.andreazin.it\/solutions\/\",\"name\":\"Note book\",\"description\":\"Appunti di un ICT Manager\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.andreazin.it\/solutions\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/e47a2b851307c3b969373910264a37ef\",\"name\":\"Andrea\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/14d0a0eb9347c19954bb41ace85b9bbe1cc906c8bf44a99f75896df0e81d154a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/14d0a0eb9347c19954bb41ace85b9bbe1cc906c8bf44a99f75896df0e81d154a?s=96&d=mm&r=g\",\"caption\":\"Andrea\"},\"sameAs\":[\"http:\/\/www.andreazin.it\"],\"url\":\"https:\/\/www.andreazin.it\/solutions\/author\/administrator\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":">>> Shift right zero fill - C#.Net porting - Note book","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.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html","og_locale":"it_IT","og_type":"article","og_title":">>> Shift right zero fill - C#.Net porting - Note book","og_description":">>> Shift Right Zero Fill in C# Continua a leggere&rarr;","og_url":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html","og_site_name":"Note book","article_published_time":"2011-06-14T09:13:32+00:00","article_modified_time":"2011-06-14T09:52:11+00:00","author":"Andrea","twitter_misc":{"Scritto da":"Andrea","Tempo di lettura stimato":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html#article","isPartOf":{"@id":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html"},"author":{"name":"Andrea","@id":"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/e47a2b851307c3b969373910264a37ef"},"headline":">>> Shift right zero fill &#8211; C#.Net porting","datePublished":"2011-06-14T09:13:32+00:00","dateModified":"2011-06-14T09:52:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html"},"wordCount":145,"commentCount":0,"keywords":["&gt;&gt;&gt;",".Net","C#","Javascript","Shift Right Zero Fill"],"articleSection":[".Net"],"inLanguage":"it-IT","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html","url":"https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html","name":">>> Shift right zero fill - C#.Net porting - Note book","isPartOf":{"@id":"https:\/\/www.andreazin.it\/solutions\/#website"},"datePublished":"2011-06-14T09:13:32+00:00","dateModified":"2011-06-14T09:52:11+00:00","author":{"@id":"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/e47a2b851307c3b969373910264a37ef"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.andreazin.it\/solutions\/shift-right-zero-fill-c-net-porting.html"]}]},{"@type":"WebSite","@id":"https:\/\/www.andreazin.it\/solutions\/#website","url":"https:\/\/www.andreazin.it\/solutions\/","name":"Note book","description":"Appunti di un ICT Manager","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.andreazin.it\/solutions\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/e47a2b851307c3b969373910264a37ef","name":"Andrea","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/www.andreazin.it\/solutions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/14d0a0eb9347c19954bb41ace85b9bbe1cc906c8bf44a99f75896df0e81d154a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/14d0a0eb9347c19954bb41ace85b9bbe1cc906c8bf44a99f75896df0e81d154a?s=96&d=mm&r=g","caption":"Andrea"},"sameAs":["http:\/\/www.andreazin.it"],"url":"https:\/\/www.andreazin.it\/solutions\/author\/administrator"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6bwSK-2X","_links":{"self":[{"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":18,"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/posts\/183\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.andreazin.it\/solutions\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}