# Split long word for average function in function block

## 11 posts in this topic

I'm building a function block to sum flow and production hous and calculate average flow based on a REAL input.

For avering I use /L function.
The Result R is a LWORD

To get a more acurate result I want to convert the result to a REAL.

The first two words of the LWORD is the Quatient in DINT
The last two words of the LWORD is the Remainder in DINT

How do I read out the remainder in a function block.

A bit shift is nog working (NASR/NSRL) is only availabe to 32 bits,'.

When not in a function block and using de D channel you simply pick the 3rd channel

LWORD = D100

D100 = DINT for QuatientA
D102 = DINT for remainder.

Edited by paulusB
attached function block

##### Share on other sites

Figured it out. You have to work with arrays and move them (as discribed in the help )

1 person likes this

##### Share on other sites

Why do math on integers and then convert to real?  That's not accurate.  Convert the numbers to real before doing to math so decimals are not rounded off.

##### Share on other sites

Because the total amounts can become big and real then les accurate

##### Share on other sites

Why not 64 bit real ?

##### Share on other sites

Thanks for the replies. I thought 64 bit real math wasn't available in CX-programmer. But it is.

Edited by paulusB
but help says only 32 bits...?

##### Share on other sites

Those are 32-bit real number commands.  I think only NJ/NX have 64-bit floating point.

##### Share on other sites

I see you are using a CJ2M PLC.  I have shown below how to use double real numbers in CXP with a CJ2M PLC.

Symbol creation:

Choose LREAL as the data type.  Be aware that this data type uses 4 consecutive 16 bit addresses.  So in this example, the variable would use D0, D1, D2 and D3.

Here are some of the double floating point instructions:

2 people like this

##### Share on other sites

CJ2 has long real so does the CP1L.

##### Share on other sites

I totally missed the "D" instructions. Thanks

##### Share on other sites

My bad... I am way behind on my knowledge of the legacy platforms, pretty much a Sysmac guy now...