I'm new in Golang and my problem is:
I have two byte arrays of 64 elements each, let's name them "A" and "B". Each of those arrays represent an unsigned integer.
I wish to produce another 64-bytes array "R" representing the result of (A / B).
Any ideas?
// pre-condition: A and B have 64 bytes each
// A and B each represent an unsigned integer
// R = (A / B)
func divideByteArrays(A, B []byte) []byte {
R := make([]byte, 64)
// ... do something ...
return R
}
Thanks in advance!
EDIT:
is it possible to use "math/big" to achieve that goal ?
https://play.golang.org/p/T5R8fB8q60
package main
import (
"math/big"
"fmt"
)
func divideByteArrays(A, B []byte) []byte {
var AI, BI, R big.Int
AI.SetBytes(A)
BI.SetBytes(B)
R.Div(&AI, &BI)
return R.Bytes()
}
func main() {
a_array := make([]byte, 64)
b_array := make([]byte, 64)
for i := 0; i < 64; i++ {
a_array[i] = 4
b_array[i] = 2
}
fmt.Println(divideByteArrays(a_array, b_array))
}