# Re: [go-nuts] Float multiplication bug?

```in the first Printf "area" is truncated. try %.40f to see the real
value, which is more like:```
```
262256.4523014638689346611499786376953125

plugging that in as h2 will result in
39709429597.00000098280725069344043731689453125 (according to wolfram
alpha)

On Thu, Feb 22, 2018 at 1:32 PM,  <steve_bagw...@sil.org> 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.

--
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.
```