# Compare floating point expressions

**URL:** <https://forum.golangbridge.org/t/compare-floating-point-expressions/2294>\
**Category:** Getting Help\
**Created:** [April 1, 2016, 1:52pm UTC](https://forum.golangbridge.org/t/compare-floating-point-expressions/2294 "2016-04-01T13:52:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chuck\_Pergiel](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/chuck_pergiel/32/1904_2.png) [@Chuck\_Pergiel](https://forum.golangbridge.org/u/Chuck_Pergiel)\
**Post date:** [April 1, 2016, 1:52pm UTC](https://forum.golangbridge.org/t/compare-floating-point-expressions/2294/1 "2016-04-01T13:52:08Z")

</div>

I thought I had a simple expression in an if statement:

```
if c2c >= (r2 + r2) { 

```

but I couldn’t make it work until I replaced (r1 + r2) with a single variable.

[https://play.golang.org/p/juhYJaoq5p](https://play.golang.org/p/juhYJaoq5p)

Am I missing something?

---

<div class="post-metadata">

**Author:** ![calmh](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/calmh/32/2896_2.png) [@calmh](https://forum.golangbridge.org/u/calmh)\
**Post date:** [April 1, 2016, 1:59pm UTC](https://forum.golangbridge.org/t/compare-floating-point-expressions/2294/2 "2016-04-01T13:59:15Z")

</div>

At first glance, your comments and your post here says `r1 + r2` but your code (even the one you quote above) says `r2 + r2`.

---

<div class="post-metadata">

**Author:** ![Chuck\_Pergiel](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/chuck_pergiel/32/1904_2.png) [@Chuck\_Pergiel](https://forum.golangbridge.org/u/Chuck_Pergiel)\
**Post date:** [April 3, 2016, 3:00pm UTC](https://forum.golangbridge.org/t/compare-floating-point-expressions/2294/3 "2016-04-03T15:00:02Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [July 2, 2016, 3:08pm UTC](https://forum.golangbridge.org/t/compare-floating-point-expressions/2294/4 "2016-07-02T15:08:02Z")

</div>

Closed on July 2, 2016, 3:08pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
