float to int

split into two integers at decimal
I'm assuming you want to get the whole number (left of the DP) into one register and the decimal/fractional part (right of the DP) into another.

Subtract 0.5 from the floating register and put the result into an N or L register. This will give you the whole number part.

Subtract this result from the original number to get the decimal part. Multiply by some factor of 10 (depending on how many decimal places you want) and move it into another integer register.
 

Similar Topics

Hi. This is pretty basic but I'm struggling to find an efficient solution. I have a float value of let say 666.555 that I want to move / split...
Replies
3
Views
201
Hello, I'm taking in two 16 bit ints from the field via modbus, one low order and one high order to combine into their proper 32-bit form. I've...
Replies
1
Views
1,273
I wrote some code in a compact logix using rs logix v.20.04 back in February. This code counts the number of pumps running a remote pump station...
Replies
12
Views
2,829
Hi Guys, i read alot of post about converting from float to int and back again but apparently i cant get it to work... *** ISSUE*** my issue is...
Replies
9
Views
2,100
Hi, I read a modbus map in array of 350 elements. The destination is integer. Now I want to copy this array into floating point array while...
Replies
3
Views
2,030
Back
Top Bottom