Subj : Serious problems with std::modf() To : borland.public.cpp.borlandcpp From : hall Date : Sat Feb 12 2005 04:37 pm Hi group. I have a serious problem concerning the function std::modf() from the header. I get the problem when compiling in BCB 6 Pro, but not in g++ under Unix. The program looks as: //--------------------------------------------------------------------------- #pragma hdrstop #include #include #pragma argsused int main(int argc, char* argv[]) { for (int i = 0; i<5; ++i) { float dummy; float f = std::modf (1.33, &dummy); std::cout << " i =" << i << std::endl; } return 0; } //--------------------------------------------------------------------------- Simple enough, i would expect that the program would output ---- i =0 i =1 i =2 i =3 i =4 --- to the screen, but it doesn't, instead it outputs --- i =1072693248 --- Can anyone here explain why? Debugging the program shows that the value of i changes form 0 to 1072693248 when modf() is executed. I can make the program act as expected by doing any of the following: 1) changing the header from to the (non-standard?) header 2) changing the type of 'dummy' to double 3) conmmenting out the line containing std::modf() and finaly 4) compiling the program as it is in g++ under linux What have I done wrong here? And how can a function call to modf() change the value of the variable i? Best regards. andreas .