Skip to content

Commit

Permalink
test math/bits
Browse files Browse the repository at this point in the history
  • Loading branch information
q191201771 committed May 4, 2020
1 parent 42654b5 commit 0f2b8ac
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions playground/p13/p13.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020, Chef. All rights reserved.
// https://github.com/q191201771/naza
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef ([email protected])

package main

import (
"fmt"
"math/bits"
)

func main() {
var a uint32
a = 1
fmt.Printf("%032b\n", a)
fmt.Printf("%032b\n", bits.ReverseBytes32(a))
a = a << 8
fmt.Printf("%032b\n", a)
fmt.Printf("%032b\n", bits.ReverseBytes32(a))

var b uint64
b = 1
fmt.Printf("%064b\n", b)
fmt.Printf("%064b\n", bits.ReverseBytes64(b))
b = b << 8
fmt.Printf("%064b\n", b)
fmt.Printf("%064b\n", bits.ReverseBytes64(b))
b = b << 8
fmt.Printf("%064b\n", b)
fmt.Printf("%064b\n", bits.ReverseBytes64(b))
}

0 comments on commit 0f2b8ac

Please sign in to comment.