Created
July 12, 2018 04:11
-
-
Save nmarley/31c25895fcd7af782eba968909c7da40 to your computer and use it in GitHub Desktop.
Split 32-bit signed tx version field into version and type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// set old (signed 32-bit) version | |
// var versionOld int32 = -987005808 | |
var versionOld int32 = 2 | |
// split into version and type fields (`type` is a reserved keyword in Go) | |
var version = int16(versionOld & 0xffff) | |
var ntype = int16((versionOld >> 16) & 0xffff) | |
// print old & new | |
fmt.Println("versionOld =", versionOld) | |
fmt.Println("version =", version) | |
fmt.Println("ntype =", ntype) | |
} | |
// this->nVersion = (int16_t) (n32bitVersion & 0xffff); | |
// this->nType = (int16_t) ((n32bitVersion >> 16) & 0xffff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment