Two 16 bit ints to One 32 bit float value
问题 I am able to extract values from modbus as 16-bit shorts (unsigned) or as ints (should be treated as 16-bit words). I am tasked to combine two values to create a single 32 bit float value using java. some example values I observed using a gui program: int + int = float 0 + 16256 = 1 0 + 17096 = 100 0 + 17097 = 100.5 0 + 17530 = 1000 8192 + 17530 = 1000.5 I attempted bit wise operators but that didn't seem to do the trick. leaves me scratching my head! 回答1: You can use Float.intBitsToFloat(int