5/15/2015 9:16 AM | |
Joined: 3/22/2010 Last visit: 10/22/2024 Posts: 76 Rating: (0) |
Dear Colleagues,
I have a problem converting 32-bit integer number to floating point value (32-bit) in WinCC VB Script editor. What I need to do is to merge 4 bytes into 32-bit value and map it to Single data type to get floating point number. Conversion needs to be done to regular format of IEEE 754 (32-bit). I have found this: https://msdn.microsoft.com/en-us/library/system.bitconverter.tosingle.aspx but I'm not able to implement that method in WinCC VBS editor as this is problably dedicated for VB not VBS/VBA editors. In C-script it is pretty easy task as I need just to point floating point area as follows: BYTE b1, b2, b3, b4; float tag_float; tag_float = (float*)(b1<<24 | b2<<16 | b3<<8 | b4); and this gives me floating point number out of 4 separate bytes. Have any of You guys faced such issue and maybe hove solution for that task in VBS?
I have base VB script: Dim b1, b2, b3, b4 Dim tag_float tag_float = b1*16777216 + b2*65536 + b3*256 + b4 '???? but this obviously gives just an integer value of DWORD.
I would appreciate help in this seemingly easy matter.
Thanks in advance for any hints.
Best greets, radek |
Follow us on