zlacker

[parent] [thread] 0 comments
1. gargar+(OP)[view] [source] 2020-03-26 14:45:51
srosenberg: you've really caught my attention here. I'm likely unqualified for the job, but I would appreciate any feedback on my approach.

WolframAlpha says ChineseRemainder[{145767, 109572}, {611939, 598463}] is 243085550

So as a golang newbie, and someone who's interested in efficient representation of strings, I tried this:

        package main

        import (
                "bytes"
                "encoding/binary"
                "fmt"
        )
        import "go.chromium.org/luci/common/data/base128"

        func main() {
                var num1 uint64 = 243085550
                buf := new(bytes.Buffer)
                err := binary.Write(buf, binary.LittleEndian, num1)
                if err != nil {
                        fmt.Println("binary.Write failed on num1:", err)
                }
                string1 := base128.EncodeToString(buf.Bytes())
                fmt.Printf("% s\n", string1)
        }

Output is wL?p?????

and of course, wLp@inpher.io bounced back.

So any feedback would appreciated in the interest of learning.

I also tried this:

        package main

        import (
                "fmt"
                "ekyu.moe/leb128"
        )

        func main() {
                fmt.Printf("%x\n", leb128.AppendUleb128(nil, 243085550))
        }
[go to top]