num

package
v0.0.0-...-1dacd80 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2022 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float32

func Float32(endian binary.ByteOrder) parser.Func[byte, float32]

Float32 reads a float32 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Float32(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

1.7378244e+34 [144 171 205 239] <nil>

func Float64

func Float64(endian binary.ByteOrder) parser.Func[byte, float64]

Float64 reads a float64 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Float64(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

-3.5987094278483163e+230 [] <nil>

func Int16

func Int16(endian binary.ByteOrder) parser.Func[byte, int16]

Int16 reads a int16 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Int16(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

13330 [86 120 144 171 205 239] <nil>

func Int32

func Int32(endian binary.ByteOrder) parser.Func[byte, int32]

Int32 reads a int32 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Int32(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

2018915346 [144 171 205 239] <nil>

func Int64

func Int64(endian binary.ByteOrder) parser.Func[byte, int64]

Int64 reads a int64 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Int64(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

-1167088091436534766 [] <nil>

func Uint16

func Uint16(endian binary.ByteOrder) parser.Func[byte, uint16]

Uint16 reads a uint16 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Uint16(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

13330 [86 120 144 171 205 239] <nil>

func Uint32

func Uint32(endian binary.ByteOrder) parser.Func[byte, uint32]

Uint32 reads a uint32 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Uint32(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

2018915346 [144 171 205 239] <nil>

func Uint64

func Uint64(endian binary.ByteOrder) parser.Func[byte, uint64]

Uint64 reads a uint64 out of the byte stream with the specified endianess.

Example
package main

import (
	"encoding/binary"
	"fmt"

	"github.com/flier/gocombine/pkg/parser/bytes/num"
)

func main() {
	p := num.Uint64(binary.LittleEndian)

	fmt.Println(p([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}))

}
Output:

17279655982273016850 [] <nil>

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL