https://en.wikipedia.org/wiki/Q_(number_format) says it all.
you can use fixed point all the way...just shift after multiplies and before divides and use double-width (int32) or wider math. On Mon, Oct 22, 2018 at 3:24 PM Vasiliy Tolstov <[email protected]> wrote: > Thanks for suggestions. > If somebody can look at github.com/unistack-org/go-crush package > (ported ceph crush to go) i'l be happy. > Now weight represented as float32, i'm try to use > https://github.com/shopspring/decimal but code looks ugly with many > conversations. And also as i see ceph code (mapper.c for crush) they > does not use something > different for weights but uint32. may be i miss something but i don't > understand how they deal with weights like 0.580 in such cases. > So if somebody wants to help - i'l be happy. > пн, 22 окт. 2018 г. в 17:14, 'Ingo Oeser' via golang-nuts > <[email protected]>: > > > > https://godoc.org/golang.org/x/image/math/fixed might provide some > hints how to work with this kind of type. > > > > The idea is to use a special type and provide all operations you need. > > > > https://godoc.org/math/big#Rat might be helpful to create first tests > of the basic math operations with maximum precision, before reducing > precision with a conversion to a more limited data type. > > > > -- > > You received this message because you are subscribed to the Google > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Vasiliy Tolstov, > e-mail: [email protected] > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- *Michael T. [email protected] <[email protected]>* -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
