experiments

All kinds of coding experiments
Log | Files | Refs | Submodules

bintest.go (407B)


      1 package main
      2 
      3 import (
      4 	"encoding/binary"
      5 	"fmt"
      6 )
      7 
      8 // PCM int with 8 bits are always unsigned. More than 8 always signed:
      9 // http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/riffmci.pdf
     10 func main() {
     11 	barr := [...]byte{0x10, 0xff}
     12 	b24 := barr[:]
     13 	fmt.Printf("%x\n", b24)
     14 	// https://golang.org/pkg/encoding/binary/#Varint
     15 	i64, n := binary.Varint(b24[:])
     16 	fmt.Println(i64)
     17 	fmt.Println(n)
     18 }