Geo.Utils

Source

Summary

float_to_hex(float, size)

Turns a float into a hex value. The size can either be 32 or 64

hex_to_float(hex)

Turns a hex string or an integer of base 16 into its floating point representation

pad_left(hex, size)

Adds 0’s to the left of hex string

pad_right(hex, size)

Adds 0’s to the right of hex string

repeat(char, count)

Repeats the char count number of times

reverse_byte_order(hex)

Reverses the byte order of the given hex string

Functions

float_to_hex(float, size)

Turns a float into a hex value. The size can either be 32 or 64.

Source
hex_to_float(hex)

Turns a hex string or an integer of base 16 into its floating point representation.

Takes an optional endian atom. Either :xdr for big endian or :ndr for little endian. Defaults to :xdr

Geo.Utils.hex_to_float("40000000")
2.0

Geo.Utils.hex_to_float(0x40000000)
2.0

Geo.Utils.hex_to_float("3ff0000000000000")
1.0

Geo.Utils.hex_to_float(0x3ff0000000000000)
1.0
Source
pad_left(hex, size)

Adds 0’s to the left of hex string

Source
pad_right(hex, size)

Adds 0’s to the right of hex string

Source
repeat(char, count)

Repeats the char count number of times

Source
reverse_byte_order(hex)

Reverses the byte order of the given hex string.

Geo.Utils.reverse_byte_order("00000004")
"40000000"

Geo.Utils.reverse_byte_order("E6100000")
"000010E6"
Source