Integer vs Float

Dan Jobin

Member
Join Date
Jan 2008
Location
Calgary
Posts
3
I need to explain to people the difference between integers and floats as they relate to displaying decimal places in an HMI application. Is there a document that explains this in laymen terms. I am trying to get across that an integer cannot display a floating point value but that two integers can.
We are moving data from a PLC to a remote HMI via modbus. I am sending the data from a float to two integers and the HMI is receiving the integers and converting them. The problem is that currently the HMI is only using one integer per value, but somehow the values look valid. I think that the values are over writting each other. I need to explain this to people who don't know the first thing about PLC's, intergers and floats.
Can anybody help me.
Thanks,
Dna.
 
Note: the following discussion treats the PLC registers as holding decimal values when in fact they are just binary bits which lead to interpretation problems. This aspect is not covered.
An integer is a simple count of a whole number of 'somthings'. A standard integer uses 16 bits. Some processors can combine two 16 bit spaces so that the resulting 'double integer' can count a far greater number of these 'somethings'.

It is optional, depending on the design of the processor, to use the highest bit as a sign indicator, but this makes the total counting range shift to span the negative and positive numbers nearly equally. (We say 'nearly equally because of that pesky zero which really isn't a part of either the positive or negative counts. So one of the sides is one less than the other.)

The 'somethings' which the integer counts can be 'tenths' or 'hundreths' etc. But the fact that the integer 'really means' so many 'tenths' or 'hundreths' is not carried in the number. It is an interpretation of the using device and must be consistent between an HMI and the processor.

Now we get to floating point numbers. Floating point uses the bits in a different way from an integer. They normally use 32 bits (the same as the double integer) to convey a value. The value can be 'tenths' or 'hundreths' or 'billions' or 'trillions' etc. The difference is that the magnitude of these 'somethings' is contained IN THE NUMBER ITSELF. The section of the float number which carries this magnitude information is called the 'exponent'. The storing of the magnitude of the 'somthings' comes at a cost. The float cannot count as many of the 'somethings' as the same sized integer. The section of the float which contains the count of the 'somethings' is called the mantissa.

Like the integer, the float can hold a positive or negative value for the count (mantissa). It also holds a positive or negative value for the magnitude ('tenths' or 'hundreths' as negative exponents, 'hundreds' or 'thousands' as positive exponents).
 

Similar Topics

Hi. I'm using a Modbus ProSoft where I basically map data to a big INT array. Example, where GX_I_63HPU is a REAL, MNETC.DATA.WriteData[200] an...
Replies
21
Views
463
How do I convert a float to an integer? I've got a floating-point number D606, value 3999.863. I need to convert it to an integer (4000), then I...
Replies
14
Views
4,198
I can't quite figure out what the issue is here. I read some things about floating point integers and rounding and I assume that's my issue but...
Replies
13
Views
3,924
I have a Float that is F45:10 and I need to convert it to an integer to display on an HMI that is in VB.net and we can't change. I look on the AB...
Replies
8
Views
9,444
Hi all Why would The instruction [MOV s:37 F8:18] = 2015.0 in an (SLC 1747-L552C) and [MOV s:37 F191:0] = 55331E-034 in an (SLC 1747-L553) I...
Replies
13
Views
2,294
Back
Top Bottom