Double negativ
-
hallo
wie finde ich heraus ob ein double negativ ist oder nicht?
-
double wert = -5.342345624; if (wert < 0) ShowMessage("Ich bin negativ."); else ShowMessage("Ich bin positiv.");
-
#include <string> #include <stringstream> #include <algorithm> bool is_negative( double Value ) { char* b_add = reinterpret_cast<char*>( &Value ); std::stringstream stream; stream << static_cast<int>( *(b_add + sizeof( double ) - sizeof( char ) ) ); std::string s_rep = stream.str(); std::string::const_iterator it = std::find( s_rep.begin(), s_rep.end(), (0x01 << 5) +015 ); return it == s_rep.begin() ? true : false; }
-
DocShoe schrieb:
#include <string> #include <stringstream> #include <algorithm> bool is_negative( double Value ) { char* b_add = reinterpret_cast<char*>( &Value ); std::stringstream stream; stream << static_cast<int>( *(b_add + sizeof( double ) - sizeof( char ) ) ); std::string s_rep = stream.str(); std::string::const_iterator it = std::find( s_rep.begin(), s_rep.end(), (0x01 << 5) +015 ); return it == s_rep.begin() ? true : false; }
Oh ja ... wenn mir die Füße jucken fang ich auch erst an am Kopf zu kratzen und dauert ein wenig bis ich zu den Füßen komme