We help IT Professionals succeed at work.

# 32 bit floating point decimal help

on
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?
Comment
Watch Question

## View Solution Only

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Use bitwise OR ( | ) combined with a left shift ( << ):

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

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

Commented:
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!
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
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.

Commented:
Thanks for the help. I didn't ask a good question.