読者です 読者をやめる 読者になる 読者になる

by shigemk2

当面は技術的なことしか書かない

F#のビット処理演算子

F#
> printfn "%x" (0x48 <<< 8);;
4800
val it : unit = ()
> printfn "%x" (0x45 <<< 8);;
4500
val it : unit = ()
> printfn "%x" (0x45 >>> 8);;
0
val it : unit = ()
> printfn "%x" (0x4500 >>> 8);;
45
val it : unit = ()
> printfn "%x" (0x4500 <<< 8);;
450000
val it : unit = ()
> printfn "%x" (0x4500 >>> 4);;
450
val it : unit = ()
> printfn "%x" (0x4500 >>> 2);;
1140
val it : unit = ()
> printfn "%x" (0x4500 >>> 4);;
450
val it : unit = ()
> printfn "%x" (0x4500 >>> 12);;
4
val it : unit = ()
> printfn "%x" (0x4500 >>> 16);;
0
val it : unit = ()
> printfn "%x" (0x4500000 >>> 4);;
450000
val it : unit = ()

4ビットで1桁ずれる。