# Understanding code

**URL:** https://discourse.processing.org/t/understanding-code/16155
**Category:** Beginners
**Created:** [December 5, 2019, 4:17pm UTC](https://discourse.processing.org/t/understanding-code/16155 "2019-12-05T16:17:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jackieh111](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jackieh111](https://discourse.processing.org/u/Jackieh111)
#### Post date: [December 5, 2019, 4:17pm UTC](https://discourse.processing.org/t/understanding-code/16155/1 "2019-12-05T16:17:53Z")

</div>

```auto
float c = ((img.pixels[(x+y*img.width)] >> 8) & 0xFF)/255.0;

```

can you tell me what this code is doing - I know it is extracting G value of RGB and then is it diving by 255 to get hex value?

Thanks!

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [December 5, 2019, 5:28pm UTC](https://discourse.processing.org/t/understanding-code/16155/2 "2019-12-05T17:28:57Z")

</div>

Hi.  
Where did you get that code?  
It really gets the float value of the green segment.  
But dividing it with 255 makes no sense to me.

---

<div class="post-metadata">

### Author: ![Jackieh111](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jackieh111](https://discourse.processing.org/u/Jackieh111)
#### Post date: [December 5, 2019, 5:39pm UTC](https://discourse.processing.org/t/understanding-code/16155/3 "2019-12-05T17:39:11Z")

</div>

I think I’ve got it Noel - I think it’s to constrain the value between 0 & 1.
