[Qt 4] abfragen, ob float-Variable Ganzzahl enthält
-
Hy,
wie kann ich ermitteln, ob in einer float Variable eine Ganzzahl gespeichert ist?
Bsp.:
float f=2.5; if (/* hat float Ganzzahl gespeichert?*/) -> false float f=4; if (/* hat float Ganzzahl gespeichert?*/) -> true
Danke schonmal
-
#include <iostream> #include <cmath> int main() { float f=2.5; if(floor(f) == f) std::cout << "1" << std::endl; f=4; if(floor(f) == f) std::cout << "2" << std::endl; }
-
Das hat eigentlich wenig mit Qt zu tun.