# How to div Values from in multiple output function arrary

**URL:** <https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978>\
**Category:** General\
**Tags:** function-node\
**Created:** [8 April 2022 11:48 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978 "2022-04-08T11:48:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![VANAJAKSHI](https://avatars.discourse-cdn.com/v4/letter/v/bc8723/32.png) [@VANAJAKSHI](https://discourse.nodered.org/u/VANAJAKSHI)\
**Post date:** [8 April 2022 11:48 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/1 "2022-04-08T11:48:06Z")

</div>

I have Written a code in function ( Multiple output ) as below which receives the data through modbus

var msg0 = {payload:(msg.payload[0]\<\<16) + msg.payload[1]};  
var msg1 = {payload:(msg.payload[2]\<\<16) + msg.payload[3]};  
return [msg0,msg1];

i'm getting msg0 output of function as as 4145 but i required 41.45. Kindly suggest what code to be written to get the expected output as 41.45.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 April 2022 11:54 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/2 "2022-04-08T11:54:30Z")

</div>

Divide it by 100

```auto
var msg0 = {payload: ((msg.payload[0]<<16) + msg.payload[1]) / 100};
var msg1 = {payload: ((msg.payload[2]<<16) + msg.payload[3]) / 100};
return [msg0,msg1];

```

At a guess, you are working with modbus data? If so, there is a contrib node designed to help with all the 16 bit / 32 bit / float / masking / bit shifting etc - makes this a trivial and low code experience - `node-red-contrib-buffer-parser`

---

<div class="post-metadata">

**Author:** ![VANAJAKSHI](https://avatars.discourse-cdn.com/v4/letter/v/bc8723/32.png) [@VANAJAKSHI](https://discourse.nodered.org/u/VANAJAKSHI)\
**Post date:** [8 April 2022 12:04 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/3 "2022-04-08T12:04:45Z")

</div>

Dear Steve,

Thanks for the reply.

Yes. We are working MODBUS DATA through ABB AC500 Controller

In Still getting the same out.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 April 2022 12:07 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/4 "2022-04-08T12:07:01Z")

</div>

can you share the values coming out of the modbus node **AND** the values you expect them to become?

(add a debug node set to `show complete message` & use the copy value button to grab a copy of the entire message)

---

<div class="post-metadata">

**Author:** ![VANAJAKSHI](https://avatars.discourse-cdn.com/v4/letter/v/bc8723/32.png) [@VANAJAKSHI](https://discourse.nodered.org/u/VANAJAKSHI)\
**Post date:** [11 April 2022 03:46 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/5 "2022-04-11T03:46:41Z")

</div>

Hi ,

The Values are coming as below.

Values 1: 32768 ,  
Values 2:17357  
Value coming : 412.  
Expected Value : 4.12

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 April 2022 05:37 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/6 "2022-04-11T05:37:47Z")

</div>

Hi could you try again please. Set the debug to show complete message & use the copy value button...

> [@Steve-Mcl](#):
>
> add a debug node set to `show complete message` & use the copy value button to grab a copy of the entire message

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 June 2022 05:37 UTC](https://discourse.nodered.org/t/how-to-div-values-from-in-multiple-output-function-arrary/60978/7 "2022-06-10T05:37:55Z")

</div>

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