jhpark 发表于 2023-7-17 18:22:13

[Question]How to convert float number via <Variable data input> ?

Hi, I'm using <Variable data input> to input my numbers as float (ex. 123.45)
with below properties :

    - Data auto-uploading : (checked)
    - Variable type : Long int(double word)
    - Integer digits : 3
    - Decimal digits : 2
    - VP(0x) : 2000

And linked it to <Data variable display> to show my number.
No problem to disaply the number on my <Data variable display>.

But, when I try to input

   9 => (11) : 5a a5 08 83 20 00 02 00 00 03 84
   1.2 => (11) : 5a a5 08 83 20 00 02 00 00 00 78

I assume "02 00 00 03 84" is 9, but how it can be converted like that ?
And how abut real float like my 1.2 ?

Could you exaplin how I can convert it to the real number via console message ?

一袋米好重 发表于 2023-7-17 20:02:28

Hello, decimals are expressed in the form of fixed point decimals, such as 0X3039 (the hexadecimal number of 12345). The specified decimal places are 2, representing 123.45,Refer to this link for the Floating-point arithmetic conversion toolhttp://inforum.dwin.com.cn:20080 ... d=1910&fromuid=9665 (出处: 迪文科技论坛)]【提问】开发应用指南的浮点数转换工具 http://inforum.dwin.com.cn:20080 ... d=1910&fromuid=9665 (出处: 迪文科技论坛)

jhpark 发表于 2023-7-19 13:46:07

Thanks alot for your info, 一袋米好重 !

I see that a first number, '2' is the position of floating point.
I'm using decimal digits to 2, and it will be 3 if my decimal digits are changed to 3...

页: [1]
查看完整版本: [Question]How to convert float number via <Variable data input> ?