Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-25 Thread Vasiliy Tolstov
ср, 24 окт. 2018 г. в 19:52, Michael Jones : > > 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. > Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@se

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-25 Thread Michael Jones
Guilty. ;-) It's also more complicated because of the desire for saturating arithmetic. On Thu, Oct 25, 2018 at 9:57 AM Scott Cotton wrote: > > > On Wednesday, 24 October 2018 18:52:27 UTC+2, Michael Jones wrote: >> >> https://en.wikipedia.org/wiki/Q_(number_format) says it all. >> >> you can u

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-25 Thread Scott Cotton
On Wednesday, 24 October 2018 18:52:27 UTC+2, Michael Jones wrote: > > 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. > > Yes, that's close enough

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-24 Thread Michael Jones
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 wrote: > Thanks for suggestions. > If somebody can look a

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-22 Thread Vasiliy Tolstov
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

[go-nuts] Q16.16 fixed point numbers in go

2018-10-22 Thread 'Ingo Oeser' via golang-nuts
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 pre

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-22 Thread Vasiliy Tolstov
Does it possible to avoid conversation and works only with fixed point (if this can bring performance speedup)? пн, 22 окт. 2018 г. в 16:13, Vasiliy Tolstov : > > пн, 22 окт. 2018 г. в 16:02, Jan Mercl <0xj...@gmail.com>: > > > > On Mon, Oct 22, 2018 at 2:35 PM Vasiliy Tolstov wrote: > > > > > Doe

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-22 Thread Vasiliy Tolstov
пн, 22 окт. 2018 г. в 16:02, Jan Mercl <0xj...@gmail.com>: > > On Mon, Oct 22, 2018 at 2:35 PM Vasiliy Tolstov wrote: > > > Does reading this 4 bytes to uint32 and use math.Float32frombits looks > > right? > > It does not look right, see > https://en.wikipedia.org/wiki/Q_(number_format)#Q_to_flo

Re: [go-nuts] Q16.16 fixed point numbers in go

2018-10-22 Thread Jan Mercl
On Mon, Oct 22, 2018 at 2:35 PM Vasiliy Tolstov wrote: > Does reading this 4 bytes to uint32 and use math.Float32frombits looks right? It does not look right, see https://en.wikipedia.org/wiki/Q_(number_format)#Q_to_float -- -j -- You received this message because you are subscribed to the

[go-nuts] Q16.16 fixed point numbers in go

2018-10-22 Thread Vasiliy Tolstov
Hi! I have some binary format that contains in 4 bytes Q16.16 fixed point number in LittleEndian. Does reading this 4 bytes to uint32 and use math.Float32frombits looks right? And also as i understand if in my code i use float32 i have performance decrease vs if i work with fixed point int? -- V