# Basic questions regarding FLT conversions and general registry

## 12 posts in this topic

Greetings. I am newly introduced to PLC programming and am still lacking in basic concepts. The current questions I have in CX Programming involve the FLT instruction and basic mathematical operations. I am building small examples of code based on principles I'd like confirmed, and if disproved I'd like explained. Let us assume, for example that I have a decimal number (&10025) that I wish to be converted to float through the FLT instruction. The manual seems to indicate that the function converts from 16bit dec to 32bit float thus adding a .0 at the end and put that result in a registry variable R and R+1, for example D100 and D101. Let us now assume that I wish to divide that value by 100 so as to obtain 100.25. Do I call a divide instruction with just the D100 (and the D101 is assumed by default) divided by &100 (does this number needs to be float as well)? Will the result be 100.25 or 100.2? How do I determine how precise the number according to my needs? Also, I assume that after conversion, every math application I use should be float based (ex: /F, *F, +F, etc), am I correct? Thank you for your assistance

##### Share on other sites
This is also correct. Always Apples to Apples and Oranges to Oranges. This is something you must also be mindful of as the instruction will perform as stated in the Instruction Help. However, if you create Symbols that define your data type, then CX Programmer will output Warnings during compile if the data types do not match.

##### Share on other sites
Greetings. Thank you for your answer. A further question, if you'd be so kind. I'm making a small program where D100 is a FLTL conversion from &10025 to D100. I am using a /F division between D100 and +100, outputing to D102, but the coloring of the /F(453) goes red when I add the .0 to 100. Red seems to be the universal indicator of an error. Any idea what I'm doing wrong?

##### Share on other sites
Can you post a screenshot?

##### Share on other sites
Here it is. If I turn the +100.0 to +100 it will go back to black (Thus I assume into a correct form)   Thanks in advance

##### Share on other sites
Maybe, but I wouldn't count on it. I believe inputting "+100" would input it in Signed Decimal format. Maybe I'm wrong. I'm not getting this error. I think I remember this limitation in a previous version of CX Programmer. What version do you have? Also, what PLC model are you using? Alternatively, you can (and what we used to do) is create your +100.0 constant by converting it from a Decimal and storing it in a DM location.

##### Share on other sites
This is correct. If you choose 'Program' from the file menu then click 'Compile', you'll get some detail in the output window.

##### Share on other sites
CX_One v4.31 installed programmer and simulator only. Regardless, your suggestion seems to be the best option, for safety if nothing else.   Thank you for your assistance.

##### Share on other sites
Also for your reference... Constants: #0100 - BCD or HEX &100 - Unsigned Decimal +/-100 - Signed Decimal +/-100.0 - Floating Point

##### Share on other sites
Maybe CXP want you to enter 100,0 instead of 100.0 if your Windows parameters has comma as numeral separator. I Had this issue when creating FB's in ST.   Edit: Just tested it. It will work with the comma. Otherwise if you want it to work with the point, change your Windows parameters. (Regional settings) Edited by pfort
1 person likes this

##### Share on other sites
version 9.51. thx for the references IO_Rack pfort is correct. it is 100,0 and not 100.0.Funny thing is, I could swear I had tested it previously. I guess I did it on one of the MOVL out of distraction.   Thank you very much