Posted 21 Mar 2014 Ok this one seems like it should be easy but I'm coming up dry on the easy way... I have a double word (unsigned) I'm reading from a scale transmitter. The sign is being sent as a separate bit. I need to convert the double unsigned word to a double signed word (DINT) Share this post Link to post Share on other sites
Posted 21 Mar 2014 (edited) Why not simply force the sign bit of the DINT ON (or OFF) based to your separate bit. If the sign bit is ON (negative) then subtract the current value from zero. If it's OFF just leave it as is. Edited 21 Mar 2014 by Mendon Systems Share this post Link to post Share on other sites
Posted 21 Mar 2014 Easy enough... Which bit is the sign bit for a double word?? Share this post Link to post Share on other sites
Posted 21 Mar 2014 The fifteenth bit of the high word. Share this post Link to post Share on other sites
Posted 21 Mar 2014 (edited) These are two separate suggestions. The 2nd suggestion is absolutely correct, if the sign bit is separate. The 1st, however is wrong. Inverting only the leftmost bit in a word is not enough for proper change of the value sign. Edited 21 Mar 2014 by Sergei Troizky Share this post Link to post Share on other sites
Posted 22 Mar 2014 Well ... yeah! I guess I didn't word that very well. To get the negative value he has to subtract the positive value from zero. He should do that when his external sign bit is ON (assuming of course that ON means negative). Share this post Link to post Share on other sites
Posted 22 Mar 2014 (edited) Yes ok Sergei, I worded that question incorrectly! I was wondering which bit is the sign WITHIN the double word. And yes I had previously tried inverting the leftmost bit and that didn't work. I will subtract the value from zero. That makes sense. Edited 22 Mar 2014 by sbaum Share this post Link to post Share on other sites