Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   [C++] Raw Bytes von float (https://www.delphipraxis.net/144464-%5Bc-%5D-raw-bytes-von-float.html)

phXql 8. Dez 2009 13:37


[C++] Raw Bytes von float
 
Hallo Leute,

ich suche in C++ eine Möglichkeit, mir die Raw Bytes eines Floats zu geben. Bei nem Int krieg ich die Raw Bytes durch einen Cast auf ein char*, bei Float geht das nicht. Gibts da eine saubere und schöne Möglichkeit?

Grüße, phXql

Niko 21. Dez 2009 14:54

Re: [C++] Raw Bytes von float
 
Hi,

das geht bei einem float genauso wie bei einem int. Eventuell verstehe ich auch nicht richtig, was du erreichen willst.

Code:
float f = 4711.42;
char *rawfloat = reinterpret_cast<char*>(&f);


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:50 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz