# Function to Convert 16 bit HEX value to float value

**URL:** <https://discourse.nodered.org/t/function-to-convert-16-bit-hex-value-to-float-value/6826>\
**Category:** General\
**Created:** [15 January 2019 07:04 UTC](https://discourse.nodered.org/t/function-to-convert-16-bit-hex-value-to-float-value/6826 "2019-01-15T07:04:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bidyutper](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bidyutper/32/1183_2.png) [@bidyutper](https://discourse.nodered.org/u/bidyutper)\
**Post date:** [15 January 2019 07:04 UTC](https://discourse.nodered.org/t/function-to-convert-16-bit-hex-value-to-float-value/6826/1 "2019-01-15T07:04:34Z")

</div>

Hi!!  
I have a piece of code wriiten in c.  
How to do this in Node red function:

> Blockquote  
> poutbuf[1] = FD;  
> pOutbuf[2] = 6F;  
> {  
> short signal;  
> float fsignal;  
> signal = (short)(pOutbuf[1]\<\<8);  
> signal += (short)(pOutbuf[2]);  
> fsignal = ((float)signal / 10.0);  
> printf("\r\GET\_Signal\t\n\n", fsignal);  
> }

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 January 2019 16:18 UTC](https://discourse.nodered.org/t/function-to-convert-16-bit-hex-value-to-float-value/6826/2 "2019-01-15T16:18:38Z")

</div>

That will convert to javascript almost as-is. You will not need to change the meaning of each line, just change to javascript syntax. You won't need the short and float typecasts.  
I don't think the first two lines are valid C though, but I imagine that is just a typo.
