Auf Thema antworten

... denn in Wirklichkeit baust Du ein (vorzeichenbehaftetes) int, das nach float konvertiert wird. Die Bit-Darstellung von Fließkommazahlen ist gänzlich anders und es ist ein erheblicher Aufwand das von Hand zu implementieren. Java hat eine solche Konvertierung zum Glück eingebaut: Float.inBitsToFloat (Auch für Double). Deine Bytes stimmen auch, es sind allerdings HIWORD und LOWORD vertauscht,

[code=Java]

System.out.println(String.format("%04X", Float.floatToIntBits(24.0f)));

System.out.println(String.format("%04X", Float.floatToIntBits(-10.0f)));

System.out.println(String.format("%04X", Float.floatToIntBits(130.0f)));

[/code]

ergibt:[CODE]

41C00000 (41h = 65, C0h = 192 - 256 = -64)

C1200000 (C1h = 193 - 256 = -63, 12h = 32)

43020000 (43h = 67, 02h = 2)

[/CODE]



Oben