
Re: What is the best way to get a Double value out of a Float32 PI point?
gregor Feb 20, 2017 2:42 PM (in response to MassimoSporchia)Hello Massimo,
I believe knowledge base article 1172OSI8 answers your questions.
The accuracy of a float32 (single) is 7 Digits.
Float32 tags should have a DisplayDigits setting of 7 or less.
Converting high precision values to lower precision results in the values being rounded off. Conversely, promoting lowprecision values to higher precision types does not lead to greater precision. The precision of a value can only decrease.
I believe the Excel example is sufficient for your example:
Excel uses double precision number in the internal representation. Therefore, float32 data may appear inaccurate because Excel can show more significant digits than a float32 can support. An entered float32 such as 29979.38 will show up as 29979.380859375 in a PI DataLink formula if the number format is left as the default, or if a format with a large number of decimal places is specified.

Re: What is the best way to get a Double value out of a Float32 PI point?
MassimoSporchia Feb 20, 2017 3:28 PM (in response to gregor)So out of the three options I should choose the one with minimum difference to the Float value.
My thought is that this difference varies based on the Single value: with number X the solution (1) is better and (2) worse, with number Y, (2) will be better than (1), etc. so it doesn't matter which one I choose?

Re: What is the best way to get a Double value out of a Float32 PI point?
gregor Feb 20, 2017 4:42 PM (in response to MassimoSporchia)1 of 1 people found this helpfulHello Massimo,
Dealing with computers means transforming an analog value into a digital representation which is close to but not equal to the analog value. The digital representation will always be a little smaller or greater compared to the analog value. If it is greater or smaller is impossible to tell without knowing the exact analog value. The precision depends on the data type e.g. 7 digits with float32 and 15 digits with float64. By storing a float32 in a float64 data type, it will again be a bit smaller or greater than the float32 but you cannot predict if this new float64 representation is closer to or less close to the analog value than the float32.
So you don't get closer to the truth than with the float32 representation. When you look at the numbers you've posted, you will recognize that there are already differences in the 6. decimal place. Based on what I am seeing, I wouldn't want to offer more than 5 decimal places: 257.78872

