On Wed, Feb 26, 2014 at 12:10 PM, Laing, Michael <michael.la...@nytimes.com> wrote: > go uses 'zig-zag' encoding, perhaps that is the difference? > > > On Wed, Feb 26, 2014 at 6:52 AM, Peter Lin <wool...@gmail.com> wrote: >> >> >> You may need to bit shift if that is the case
Thanks for everybody's help, I've managed to solve the issue: the unscaled part of the decimal needs to be encoded using two's compliment. Neither the standard Go big.Rat type nor the more amenable replacement inf.Dec use two's compliment encoding, which is what Java BigDecimal and the other languages are doing. Ironically, the code to do the two's compliment packing and unpacking is available in the the asn1 module of the standard Go library. Unfortunately the functions are not exported outside the package scope, since they designed for internal use only. So open source to the rescue. Hopefully the gocql team can code review this soon and if that's good to go, we'll have another CQL driver that can deal with decimals.