{"id":331,"date":"2022-01-04T10:27:31","date_gmt":"2022-01-04T09:27:31","guid":{"rendered":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/?p=331"},"modified":"2022-01-11T11:51:59","modified_gmt":"2022-01-11T10:51:59","slug":"representation-de-donnees-types-et-valeurs-de-base","status":"publish","type":"post","link":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/2022\/01\/04\/representation-de-donnees-types-et-valeurs-de-base\/","title":{"rendered":"Repr\u00e9sentation de donn\u00e9es : types et valeurs de base"},"content":{"rendered":"\n<p class=\"has-text-color has-background\" style=\"background-color:#ffd3de;color:#ff5982\"><strong>1) \u00c9criture d\u2019un entier positif dans une base b \u2a7e 2<\/strong><\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color has-background\" style=\"background-color:#ccffeb\"><strong>Test de scripts : <\/strong><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-background\" style=\"background-color:#c8eaff\"><strong>Conversion d&rsquo;un nombre en base 2 avec la fonction bin()<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nombre=21\nbin(nombre)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"149\" height=\"34\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-17.png\" alt=\"\" class=\"wp-image-340\" \/><\/figure>\n\n\n\n<p><em>Python interpr\u00e8te les nombres commen\u00e7ant par 0b comme des nombres binaires<\/em>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=0b1100\nprint(a)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"105\" height=\"29\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-18.png\" alt=\"\" class=\"wp-image-341\" \/><\/figure>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-background\" style=\"background-color:#c8eaff\"><strong>Conversion d&rsquo;un nombre en base 16 avec la fonction hex()<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=31\nnombre=hex(a)\nprint(nombre)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"117\" height=\"32\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-19.png\" alt=\"\" class=\"wp-image-342\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=0x1F\nprint(a)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"107\" height=\"28\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-20.png\" alt=\"\" class=\"wp-image-343\" \/><\/figure>\n\n\n\n<p><em>Expliquez le r\u00e9sultat de l&rsquo;op\u00e9ration ci-dessous<\/em> :<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=0x1f+0b1100\nprint(a)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"109\" height=\"30\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-21.png\" alt=\"\" class=\"wp-image-344\" \/><\/figure>\n\n\n\n<p>0b1100 correspond \u00e0 12 tandis que 0x1f correspond \u00e0 31. <\/p>\n\n\n\n<p>Lorqu&rsquo;on additionne les deux cela nous donne 43.<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-background\" style=\"background-color:#c8eaff\"><strong>Convertisseur en base 2 et 16<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nombre=int(input(\"entier en base 10 : \"))\nprint(\"en base 2 : \"+ str(bin(nombre))[2:])\nprint(\"en base 16 : \"+ str(hex(nombre))[2:])<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"231\" height=\"59\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-22.png\" alt=\"\" class=\"wp-image-345\" \/><\/figure>\n\n\n\n<p><em>Testez la fonction ci-dessous puis expliquez<\/em> :<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def binaire(n):\n           q=n\n           bin=''\n           while q!=0:\n                      r=q%2\n                      q=q\/\/2\n                      bin=str(r)+bin\n           return bin<\/pre>\n\n\n\n<ul><li>On d\u00e9finit une fonction &lsquo;binaire&rsquo;<\/li><li>On attribue n \u00e0 q<\/li><li>On attribue &lsquo; &lsquo; \u00e0 bin<\/li><li>Tant que q est diff\u00e9rent de 0 :<ul><li>r= le reste de la division de q par 2<\/li><li>q= la division enti\u00e8re de q par 2<\/li><li>bin est \u00e9gal \u00e0 r (chaine de caract\u00e8res) + bin<\/li><\/ul><\/li><li>renvoyer bin<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=124\nnombre=binaire(a)\nprint(nombre)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"143\" height=\"31\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-23.png\" alt=\"\" class=\"wp-image-348\" \/><\/figure>\n\n\n\n<p><em>Quel est le plus grand entier naturel cod\u00e9 sur 8 bits ?<\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">n=0b11111111\nprint(n)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"107\" height=\"25\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-24.png\" alt=\"\" class=\"wp-image-349\" \/><\/figure>\n\n\n\n<p>On peut coder 256 entiers sur 8 bits.<\/p>\n\n\n\n<p>Soit 255 +1 pour le 0.<\/p>\n\n\n\n<p>Ou 2^8<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-background\" style=\"background-color:#c8eaff\"><strong>Conversion base b base 10<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def mystere(x,b=2):\n  u = 0\n  for a in x:\n    u = b * u + int(a)\n  return u<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=base10(\"11001\")\nprint(a)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"101\" height=\"26\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-25.png\" alt=\"\" class=\"wp-image-350\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=base10(\"11001\",2)\nprint(a)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"110\" height=\"30\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-26.png\" alt=\"\" class=\"wp-image-351\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a=base10(\"11001\",10)\nprint(a)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"122\" height=\"27\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-27.png\" alt=\"\" class=\"wp-image-352\" \/><\/figure>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color has-background\" style=\"background-color:#ccffeb\"><strong>Combien d\u00e9nombrez-vous d\u2019animaux&nbsp;?<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"http:\/\/yb-isn.fr\/nsi2019\/wp-content\/uploads\/2019\/10\/animaux.png\" alt=\"L\u2019attribut alt de cette image est vide, son nom de fichier est animaux.png.\" width=\"443\" height=\"229\" \/><\/figure>\n\n\n\n<p>Notre r\u00e9ponse est 18 en repr\u00e9sentation d\u00e9cimale.<\/p>\n\n\n\n<p>On peut pr\u00e9ciser si n\u00e9cessaire&nbsp;: (18)<sub>10<\/sub><\/p>\n\n\n\n<p>On peut \u00e9crire&nbsp;des repr\u00e9sentations diff\u00e9rentes du m\u00eame nombre d\u2019animaux : (18)<sub>10<\/sub>= (00010010)<sub>2<\/sub>= (12)<sub>16<\/sub>= (22)<sub>8<\/sub><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/yb-isn.fr\/nsi2019\/wp-content\/uploads\/2019\/10\/calcwin19-1.png\" alt=\"\" \/><\/figure>\n\n\n\n<p>Avec la calculatrice de Windows 10 en mode programmeur. l\u2019\u00e9criture binaire a \u00e9t\u00e9 compl\u00e9t\u00e9e avec des \u00ab&nbsp;z\u00e9ros&nbsp;\u00bb \u00e0 gauche pour avoir un codage sur 8 bits.<\/p>\n\n\n\n<p>Pour repr\u00e9senter un nombre n en base 10, on doit utiliser 10 caract\u00e8res<br>diff\u00e9rents pour repr\u00e9senter les 10 premiers entiers : 0 1 2 3 4 5 6 7 8 9,<br>et d\u00e9composer les entiers suivants \u00e0 l\u2019aide des puissances de 10 successives.<br>Par exemple, 19 repr\u00e9sente le nombre 1 \u00d7 10<sup>1<\/sup>&nbsp;+ 9 \u00d7 10<sup>0<\/sup><\/p>\n\n\n\n<p>En base 2 (binaire) on a 2 symboles 0 et 1.<\/p>\n\n\n\n<p>En base 16 (hexad\u00e9cimal) on 16 symboles&nbsp;: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F<\/p>\n\n\n\n<p>La valeur de A est 10 et F est 15.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">Un entier naturel est un entier positif ou nul. Pour coder des nombres entiers naturels compris entre 0 et 255, il nous suffira de 8 bits (un octet) . D\u2019une mani\u00e8re g\u00e9n\u00e9rale un codage sur&nbsp;<em>n<\/em>&nbsp;bits pourra permettre de repr\u00e9senter des nombres entiers naturels compris entre 0 et 2<sup>n<\/sup>-1 .<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">Chacun des nombres 0 ou 1 de l\u2019\u00e9criture binaire est appel\u00e9 bit.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/yb-isn.fr\/nsi2019\/wp-content\/uploads\/2019\/10\/bit.png\" alt=\"\" \/><\/figure>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">Il est n\u00e9cessaire de fixer la taille de cette suite finie de bits pour coder les entiers naturels en machine.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">Lorsque les nombres sont repr\u00e9sent\u00e9s par plusieurs octets, la machine doit fixer l\u2019ordre en m\u00e9moire de ces octets. On parle de&nbsp;<a href=\"https:\/\/fr.wikipedia.org\/wiki\/Boutisme\">boutisme<\/a>&nbsp;ou endianness en anglais. La m\u00e9moire des ordinateurs est divis\u00e9es en blocs de 8 bits (soit un octet). Un processeur 64 bits par exemple manipule des paquets de 8 octets, soit 64 bits .<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">Dans une base b, on utilise b symboles distincts pour repr\u00e9senter les nombres. La valeur de chaque symbole doit \u00eatre strictement inf\u00e9rieur \u00e0 b.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color has-background\" style=\"background-color:#ccffeb\"><strong>Addition de nombres binaires :<\/strong><\/p>\n\n\n\n<p>Effectuer cette addition de deux nombres binaires cod\u00e9s sur 8 bits sans faire de conversion.V\u00e9rifier le r\u00e9sultat obtenu en effectuant les conversions.<\/p>\n\n\n\n<p>(00110011)<sub>2<\/sub>+ (00011100)<sub>2<\/sub><br>= (01001111)<sub>2<\/sub> <\/p>\n\n\n\n<p>Soit 51 + 28 = 79<\/p>\n\n\n\n<p>Une autre addition :<\/p>\n\n\n\n<p>(10110011)<sub>2<\/sub>+ (01011100 )<sub>2<\/sub><br>= (100001111)<sub>2<\/sub> <\/p>\n\n\n\n<p>Soit 179 + 92 = 271<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-background\" style=\"background-color:#bbe5ff\"><strong>Les couleurs en h\u00e9xad\u00e9cimal :<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>1)Construire un dictionnaire qui attribue les valeurs aux symboles hexad\u00e9cimaux<\/strong><\/p>\n\n\n\n<p>&lsquo;Un triplet hexad\u00e9cimal est un nombre hexad\u00e9cimal \u00e0 6 chiffres m\u00e9moris\u00e9 sur trois octets utilis\u00e9 en HTML et dans les feuilles de style en cascade (CSS), et d&rsquo;autres applications, pour repr\u00e9senter les couleurs. Les octets repr\u00e9sentent les composantes rouge, vert et bleu de la couleur.<\/p>\n\n\n\n<p>Un octet repr\u00e9sente l&rsquo;intervalle entre 00 et FF (en notation hexad\u00e9cimale), ou 0 \u00e0 255 en notation d\u00e9cimale. Le triplet hexad\u00e9cimal est form\u00e9 par la concat\u00e9nation de trois octets en notation hexad\u00e9cimale, dans l&rsquo;ordre rouge-vert-bleu. Les trois groupes de deux chiffres hexad\u00e9cimaux se suivent sans espace apr\u00e8s un croisillona. Les z\u00e9ros initiaux, non significatifs, doivent figurer, pour garder le nombre de chiffres dans les triplets \u00e9gal \u00e0 six.<\/p>\n\n\n\n<p>Par exemple, le triplet 0,1,2 devrait \u00eatre repr\u00e9sent\u00e9 par le code #000102&prime;<\/p>\n\n\n\n<p><strong>2)Ecrire une fonction permettant de trouver la repr\u00e9sentation RGB d&rsquo;une couleur \u00e0 partir la repr\u00e9sentation hexad\u00e9cimale.<\/strong><\/p>\n\n\n\n<p><strong>Effectuez un test avec la couleur lightsalmon ci-dessous.<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.w3schools.com\/colors\/colors_picker.asp\">https:\/\/www.w3schools.com\/colors\/colors_picker.asp<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color has-background\" style=\"background-color:#ccffeb\"><strong>Corrig\u00e9 :<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#construction d'un dictionnaire\ns = '0123456789ABCDEF'\ndic = {}\nfor i in range(16):\n    dic[s[i]] = i\nprint(dic)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"29\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-28-1024x29.png\" alt=\"\" class=\"wp-image-361\" srcset=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-28-1024x29.png 1024w, http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-28-300x9.png 300w, http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-28-768x22.png 768w, http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-28.png 1045w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lightsalmon=\"#FFA07A\"<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#convertisseur\ndef color_rgb(color_hexa):\n    red=color_hexa[1:3]\n    R=dic[red[0]]*16+dic[red[1]]\n\n    green=color_hexa[3:5]\n    G=dic[green[0]]*16+dic[green[1]]\n\n    blue=color_hexa[5:7]\n    B=dic[blue[0]]*16+dic[blue[1]]\n    return(R,G,B)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#test\ncolor_rgb(lightsalmon)<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"129\" height=\"32\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-29.png\" alt=\"\" class=\"wp-image-362\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"193\" height=\"152\" src=\"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-content\/uploads\/sites\/8\/2022\/01\/image-30.png\" alt=\"\" class=\"wp-image-363\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-background\" style=\"background-color:#ffd3de;color:#ff5982\"><strong>2 &#8211; Repr\u00e9sentation binaire d\u2019un entier relatif<\/strong><\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">Le compl\u00e9ment \u00e0 deux est une technique qui consiste \u00e0 inverser tout les bits de la repr\u00e9sentation binaire d\u2019un nombre entier puis \u00e0 rajouter 1 pour obtenir la repr\u00e9sentation binaire de l\u2019entier relatif oppos\u00e9.<\/p>\n\n\n\n<ul><li>Ecrire 45 en binaire<\/li><\/ul>\n\n\n\n<p>(00101101)<sub>2<\/sub>  <\/p>\n\n\n\n<ul><li>Inverser les bits<\/li><\/ul>\n\n\n\n<p>(11010010)<sub>2<\/sub>   <\/p>\n\n\n\n<ul><li>Ajouter 1<\/li><\/ul>\n\n\n\n<p>(11010011)<sub>2<\/sub>   <\/p>\n\n\n\n<ul><li>Additionner en binaire le nombre obtenu et son compl\u00e9ment \u00e0 2<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<ul><li>Conclure<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1) \u00c9criture d\u2019un entier positif dans une base b \u2a7e 2 Test de scripts : Conversion d&rsquo;un nombre en base 2 avec la fonction bin() Python interpr\u00e8te les nombres commen\u00e7ant par 0b comme des nombres binaires. Conversion d&rsquo;un nombre en base 16 avec la fonction hex() Expliquez le r\u00e9sultat de l&rsquo;op\u00e9ration ci-dessous : 0b1100 correspond [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":334,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/posts\/331"}],"collection":[{"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/comments?post=331"}],"version-history":[{"count":12,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":368,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/posts\/331\/revisions\/368"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/media\/334"}],"wp:attachment":[{"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/media?parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/categories?post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yb-isn.fr\/2021\/nsi\/anna\/wp-json\/wp\/v2\/tags?post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}