Negatieve getallen omzetten naar binair
-
- Berichten: 2
Negatieve getallen omzetten naar binair
Hallo,
Kan er iemand mij simpel uitleggen hoe decimaal negatieve getallen kunnen omgezet worden in het binair?
5 = 101
12 = 1100
78 = 1001110
maar wat nu met -12 of -5 bv? Hoe wordt dit correct omgezet voor élk decimaal getal? De meest linkse bit is hier altijd de sign bit(+ of -).
Kan er iemand mij simpel uitleggen hoe decimaal negatieve getallen kunnen omgezet worden in het binair?
5 = 101
12 = 1100
78 = 1001110
maar wat nu met -12 of -5 bv? Hoe wordt dit correct omgezet voor élk decimaal getal? De meest linkse bit is hier altijd de sign bit(+ of -).
- Berichten: 5.609
Re: Negatieve getallen omzetten naar binair
Met welk systeem? Er zijn verschillende systemen om dit te doen... 2's complement komt wel het vaakst voor.Jimbo84 schreef:Hallo,
Kan er iemand mij simpel uitleggen hoe decimaal negatieve getallen kunnen omgezet worden in het binair?
5 = 101
12 = 1100
78 = 1001110
maar wat nu met -12 of -5 bv? Hoe wordt dit correct omgezet voor élk decimaal getal? De meest linkse bit is hier altijd de sign bit(+ of -).
What it all comes down to, is that I haven't got it all figured out just yet
And I've got one hand in my pocket and the other one is giving the peace sign
-Alanis Morisette-
And I've got one hand in my pocket and the other one is giving the peace sign
-Alanis Morisette-
-
- Berichten: 2
Re: Negatieve getallen omzetten naar binair
In het 2-complement systeem inderdaad...Met welk systeem? Er zijn verschillende systemen om dit te doen... 2's complement komt wel het vaakst voor.
- Berichten: 5.609
Re: Negatieve getallen omzetten naar binair
Wat begrijp je er precies niet aan? Waarvoor wil je het gebruiken?In het 2-complement systeem inderdaad...
Er staat op wiki al heel erg duidelijke (zij het uitgebreide) uitleg hierover.
In het kort is de manier van werken alle bits inverteren, en 1 bij optellen.
12 is 00001100
Na inverteren wordt dat 11110011
+1 waarbij je 11110011 als het getal 243 interpreteerd, wordt dat 11110100
-12 is dus 11110100
Willen we -12 inverteren, dan krijgen we
00001011
+1 wordt dat 00001100, wat zoals verwacht, 12 is.
What it all comes down to, is that I haven't got it all figured out just yet
And I've got one hand in my pocket and the other one is giving the peace sign
-Alanis Morisette-
And I've got one hand in my pocket and the other one is giving the peace sign
-Alanis Morisette-