Saturday, March 11, 2023
HomeGolangWhy does int8 left bitshift ended up being adverse on 8th little...

Why does int8 left bitshift ended up being adverse on 8th little bit? – Obtaining Assistance


https://play.golang.com/p/TyFQoBR9dQr

plan primary

import (
” fmt”
)

func primary() {
var c int8 = 1// 00000001
fmt.Println( c << < < 6)// 01000000 = 64
fmt.Println( c << < < 7)// 10000000 = -128???
}


Due to the fact that the int8 is anonymous – so the last little bit determines the instructions



1 Like

It resembles you might have currently figured it out, however please see 2’s enhance – Wikipedia to find out more on what’s taking place.



2 Sorts

if initial little bit begins with 1 it’s an unfavorable number, or else a favorable one

RELATED ARTICLES

Most Popular

Recent Comments