# Why is hex(255,2) != hex(255,2)?

**URL:** <https://discourse.processing.org/t/why-is-hex-255-2-hex-255-2/44274>\
**Category:** Beginners\
**Created:** [April 14, 2024, 12:12am UTC](https://discourse.processing.org/t/why-is-hex-255-2-hex-255-2/44274 "2024-04-14T00:12:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbcwarrior](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@bbcwarrior](https://discourse.processing.org/u/bbcwarrior)\
**Post date:** [April 14, 2024, 12:12am UTC](https://discourse.processing.org/t/why-is-hex-255-2-hex-255-2/44274/1 "2024-04-14T00:12:32Z")

</div>

Why doesn’t this piece of code output anything:

```auto
  if(hex(255,2) == hex(255,2)) {
    println("foo");
  }

```

But this one does?:

```auto
  if(unhex(hex(255,2)) == unhex(hex(255,2))) {
    println("bar");
  }

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 14, 2024, 12:15am UTC](https://discourse.processing.org/t/why-is-hex-255-2-hex-255-2/44274/2 "2024-04-14T00:15:47Z")

</div>

Hello @bbcwarrior.

When comparing strings:

```auto
if( hex(255,2).equals( hex(255,2) ) ) {
    println("foo");
  }

```

References:

- [hex() / Reference / Processing.org](https://processing.org/reference/hex_.html)
- [String / Reference / Processing.org](https://processing.org/reference/String.html)

`:)`
