Ero sivun ”Heksadesimaalijärjestelmä” versioiden välillä

[katsottu versio][katsottu versio]
Poistettu sisältö Lisätty sisältö
EmausBot (keskustelu | muokkaukset)
p r2.7.3) (Botti muokkasi: pt:Sistema de numeração hexadecimal
Taulukko yksinkertaistettu ja algoritmi lisätty
Merkkaus:  virheellinen wikikoodi 
Rivi 1:
{|- class="wikitable" align="right"
{| border="0" cellspacing="0" cellpadding="0" style="text-align:center;border:2px" align=right
! Heksadesimaali
|- style="background:black; height:2px"
! Binääri
| style="background:black; width:2px" | || || || || || || || || || || ||
! Desimaali
|-style="background:#FDC888; color:black; height:24px"
! Oktaali
| style="background:black; width:2px" | || style="width:45px"|'''0'''<sub>hex</sub> || = || style="width:45px"|0<sub>dec</sub> || = || style="width:45px"|0<sub>oct</sub> ||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0 ||style="background:black; width:2px" |
|-
|-style="background:#E3EDE9; color:black; height:24px"
|align="right"|#0
| style="background:black; width:2px" | || '''1'''<sub>hex</sub> || = || 1<sub>dec</sub> || = || 1<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|0
|-style="background:#E3EDE9; color:black; height:24px"
|align="right"|0
| style="background:black; width:2px" | || '''2'''<sub>hex</sub> || = || 2<sub>dec</sub> ||= || 2<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|align="right"|00
|-style="background:#FDC888; color:black; height:24px"
|-
| style="background:black; width:2px" | || '''3'''<sub>hex</sub> || = || 3<sub>dec</sub> || = || 3<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|#1
|- style="background:black; height:2px"
|align="right"|1
| style="background:black; width:2px" | || || || || || || || || || || ||
|align="right"|1
|-style="background:#E3EDE9; color:black; height:24px"
|align="right"|01
| style="background:black; width:2px" | || '''4'''<sub>hex</sub> || = || 4<sub>dec</sub> ||= || 4<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|-
|-style="background:#FDC888; color:black; height:24px"
|align="right"|#2
| style="background:black; width:2px" | || '''5'''<sub>hex</sub> || = || 5<sub>dec</sub> || = || 5<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|10
|-style="background:#FEE978; color:black; height:24px"
|align="right"|2
| style="background:black; width:2px" | || '''6'''<sub>hex</sub> || = || 6<sub>dec</sub> ||= || 6<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|align="right"|02
|-style="background:#E3EDE9; color:black; height:24px"
|-
| style="background:black; width:2px" | ||'''7'''<sub>hex</sub> || = || 7<sub>dec</sub> || = || 7<sub>oct</sub>||style="background:black; width:2px" | || style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|#3
|- style="background:black; height:2px"
|align="right"|11
| style="background:black; width:2px" | || || || || || || || || || || ||
|align="right"|3
|-style="background:#E3EDE9; color:black; height:24px"
|align="right"|03
| style="background:black; width:2px" | || '''8'''<sub>hex</sub> || = || 8<sub>dec</sub> || = || 10<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|-
|-style="background:#FEE978; color:black; height:24px"
|align="right"|#4
| style="background:black; width:2px" | || '''9'''<sub>hex</sub> || = || 9<sub>dec</sub> ||= || 11<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|100
|-style="background:#FDC888; color:black; height:24px"
|align="right"|4
| style="background:black; width:2px" | || '''A'''<sub>hex</sub>|| = || 10<sub>dec</sub> || = || 12<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|align="right"|04
|-style="background:#E3EDE9; color:black; height:24px"
|-
| style="background:black; width:2px" | || '''B'''<sub>hex</sub>|| = || 11<sub>dec</sub> || = || 13<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|#5
|- style="background:black; height:2px"
|align="right"|101
| style="background:black; width:2px" | || || || || || || || || || || ||
|align="right"|5
|-style="background:#FDC888; color:black; height:24px"
|align="right"|05
| style="background:black; width:2px" | || '''C'''<sub>hex</sub>|| = || 12<sub>dec</sub> || = || 14<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|-
|-style="background:#E3EDE9; color:black; height:24px"
|align="right"|#6
| style="background:black; width:2px" | || '''D'''<sub>hex</sub>|| = || 13<sub>dec</sub> ||= || 15<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|110
|-style="background:#E3EDE9; color:black; height:24px"
|align="right"|6
| style="background:black; width:2px" | || '''E'''<sub>hex</sub>|| = || 14<sub>dec</sub> ||= || 16<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:white;width:24px"|0||style="background:black; width:2px" |
|align="right"|06
|-style="background:#FDC888; color:black; height:24px"
|-
| style="background:black; width:2px" | || '''F'''<sub>hex</sub>|| = || 15<sub>dec</sub> || = || 17<sub>oct</sub>||style="background:black; width:2px" | || style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1|| style="background:red;width:24px"|1||style="background:black; width:2px" |
|align="right"|#7
|- style="background:black; height:2px"
|align="right"|111
| style="background:black; width:2px" | || || || || || || || || || || ||
|align="right"|7
|align="right"|07
|-
|align="right"|#8
|align="right"|1000
|align="right"|8
|align="right"|010
|-
|align="right"|#9
|align="right"|1001
|align="right"|9
|align="right"|011
|-
|align="right"|#a
|align="right"|1010
|align="right"|10
|align="right"|012
|-
|align="right"|#b
|align="right"|1011
|align="right"|11
|align="right"|013
|-
|align="right"|#c
|align="right"|1100
|align="right"|12
|align="right"|014
|-
|align="right"|#d
|align="right"|1101
|align="right"|13
|align="right"|015
|-
|align="right"|#e
|align="right"|1110
|align="right"|14
|align="right"|016
|-
|align="right"|#f
|align="right"|1111
|align="right"|15
|align="right"|017
|-
|align="right"|#10
|align="right"|10000
|align="right"|16
|align="right"|020
|-
|align="right"|#11
|align="right"|10001
|align="right"|17
|align="right"|021
|-
|align="right"|#12
|align="right"|10010
|align="right"|18
|align="right"|022
|-
|align="right"|#13
|align="right"|10011
|align="right"|19
|align="right"|023
|-
|align="right"|#14
|align="right"|10100
|align="right"|20
|align="right"|024
|-
|align="right"|#15
|align="right"|10101
|align="right"|21
|align="right"|025
|-
|align="right"|#16
|align="right"|10110
|align="right"|22
|align="right"|026
|-
|align="right"|#17
|align="right"|10111
|align="right"|23
|align="right"|027
|-
|align="right"|#18
|align="right"|11000
|align="right"|24
|align="right"|030
|-
|align="right"|#19
|align="right"|11001
|align="right"|25
|align="right"|031
|-
|align="right"|#1a
|align="right"|11010
|align="right"|26
|align="right"|032
|-
|align="right"|#1b
|align="right"|11011
|align="right"|27
|align="right"|033
|-
|align="right"|#1c
|align="right"|11100
|align="right"|28
|align="right"|034
|-
|align="right"|#1d
|align="right"|11101
|align="right"|29
|align="right"|035
|-
|align="right"|#1e
|align="right"|11110
|align="right"|30
|align="right"|036
|}
 
 
'''Heksadesimaalijärjestelmä''' on [[kantalukujärjestelmä]], jonka kantaluku on 16. Sitä käytetään yleisesti [[tietotekniikka|tietotekniikassa]], koska yksi 16-kantaisen järjestelmän merkki vastaa suoraan binäärijärjestelmän neljää peräkkäistä [[bitti]]ä. Näin esimerkiksi 8-bittisen tavun arvo voidaan ilmaista kahden merkin pituisella heksadesimaaliluvulla.
Rivi 49 ⟶ 167:
 
Ohjelmoinnissa heksadesimaaliluvut erotetaan desimaaliluvuista muun muassa seuraavin tavoin:
* #f3
* \xAB
* 0xCD (esimerkiksi [[C (ohjelmointikieli)|C]] johdannaisineen)
Rivi 58 ⟶ 177:
* x'40'
* '00'x
 
Ohjelmoinnissa voidaan käyttää myös [[oktaaliluku]]ja, joiden kantaluku on kahdeksan. Oktaaliluvut erotetetaan muistaluvuista laittamalla eteen nolla. Esim. 071.
 
''Hexadecimal''-sanan otti ensimmäisenä käyttöön [[IBM]], joka halusi korvata aiemman sexidecimal-sanan.{{lähde}}
Rivi 79 ⟶ 200:
* 160<sub>10</sub> = A0<sub>16</sub>
* 255<sub>10</sub> = FF<sub>16</sub>
 
== Heksasesimaali desimaaliksi ==
 
* #f <math> = (15 \cdot 16^0) = 15</math>
* #51 <math> = (5 \cdot 16^1) + (1 \cdot 16^0) = 81</math>
* #1ad <math> = (1 \cdot 16^2) + (11 \cdot 16^1) + (13 \cdot 16^0) = 429</math>
* #95f9 <math> = (9 \cdot 16^3) + (5 \cdot 16^2) + (15 \cdot 16^1) + (9 \cdot 16^0) = 38393</math>
* #3f4d0 <math> = (3 \cdot 16^4 ) + (15 \cdot 16^3) + (4 \cdot 16^2) + (13 \cdot 16^1) + (0 \cdot 16^0) = 259280</math>
 
Samaa systeemiä voi soveltaa muihinkin lukujärjesteliin
 
== Katso myös ==