[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

32 bit floating point decimal help

Posted on 2012-08-14
4
Medium Priority
?
450 Views
Last Modified: 2012-08-18
I've got a 32 bit floating point decimal at a device. It's split into two 16 bit integers to go over the wire.

The original value, at the device, is 156.

The two 16 bit integers come across as 17180 and 0. How do I convert, in C#, the 17180 and 0 back to 156?
0
Comment
Question by:lateapex
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38293663
Use bitwise OR ( | ) combined with a left shift ( << ):

int result = (int1 << 16) | int2;

Open in new window


be sure to put them in the correct order of higher-order bits and lower-order bits (higher on the left of the |).
0
 

Author Comment

by:lateapex
ID: 38293711
So I tried this:

 int myFirst = 17180;
            int mySecond = 0;
            int myResult = myFirst | mySecond;

myResult came out to 17180.

I'm trying put the two back together to form a 32 bit floating point that I know left the device with a value of 156.

The reason for this is the device sometimes reverses the order of the two 16 bit integers and we need to debug.

Thanks!
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 38293784
I edited my post (not quick enough it seems). You need a left-shift as well. However, I don't see how you could possibly get back a number that is smaller than either of its two parts. I think something isn't correct in the initial conversion.
0
 

Author Closing Comment

by:lateapex
ID: 38308229
Thanks for the help. I didn't ask a good question.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question