How can I convert 2 16 bit shorts into a 32 bit single and back again

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to convert a csv file of 16 bit shorts (signed ints) variables into singles (32 bit float). The problem is the source file comes from a plc with fixed sequential registers were 16 bit integers and 32 bit floats are all saved in a sequential series of 16 bit registers whose contents are then placed 16bits at a time into a csv file. This has the effect of creating several  32 bit floats from 2 16 bit ints without regard to the actual values.
I then need to manipulate the data as 32 bit singles, then break the singles into 2 16bit shorts before placing them back into the csv file for consumption by the plc.
Has anyone done anything similar.
F.M.
 
 

View the full article
 
Back
Top