Dave, try this version: https://play.golang.org/p/p5zyQF1Sdr
From: <golang-nuts@googlegroups.com> on behalf of Jan Mercl <0xj...@gmail.com> Date: Monday, October 10, 2016 at 4:40 PM To: Dave Cohen <davecohe...@gmail.com>, golang-nuts <golang-nuts@googlegroups.com> Subject: Re: [go-nuts] big.Rat anomalies On Mon, Oct 10, 2016 at 4:29 PM Dave Cohen <davecohe...@gmail.com> wrote: > numerator.SetFloat64(118.5285714285714) // becomes > 118.528571428571396495499357115477 > big.NewRat(592642857142857, 5000000000000) // becomes > 118.528571428571400000000000000000 - more accurate than SetFloat64 above! > > So my first question is why is SetFloat64() less accurate than the ratio used > in NewRat() above? A float64 number has only 53 bits of mantissa precision while the result of big.NewRat is always exact (has infinite precision). -- -j -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.