One subtle thing is the difference between an ideal number, its floating-point representation, and its printed form.
On Fri, Feb 23, 2018 at 5:46 AM, <steve_bagw...@sil.org> wrote: > Thanks guys. That's very helpful. I forgot that what I saw (and re-used) > as the "height" was not precise enough to make it comparable. > > > On Thursday, February 22, 2018 at 3:33:38 PM UTC-5, Steve Bagwell wrote: >> >> >> Hello Everyone, >> >> This looks like a Golang bug to me. What do you all think? >> >>> I have this function ... >> >> func getArea(base, side int64) float64 { >>> var height, fSide, area float64 >>> fSide = float64(side) >>> halfBase := float64(base) / 2.0 >>> height = math.Sqrt(fSide*fSide - halfBase*halfBase) >>> area = halfBase * height >>> fmt.Printf("halfBase: %f, height: %f, Area: %f\n", halfBase, height, >>> area) >>> >> >> >>> hb2 := 151414.5 >>> h2 := 262256.452301 >>> fmt.Printf("Area 2: %f\n", hb2 * h2) >>> >> >> >>> return area >>> } >> >> >> When I call it with `result := getArea(302829, 302828)`, I get this >> output ... >> >> halfBase: 151414.500000, height: 262256.452301, Area: 39709429597.000000 >>> Area 2: 39709429596.929764 >> >> >> I could see how some kind of rounding could produce the first Area >> value. But in that case, why wouldn't Area2 be rounded as well? >> > -- > 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. > -- Michael T. Jones michael.jo...@gmail.com -- 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.