how to get the number of digits
-
how to get the number of digits after the decimal point ex : Input : 5.1234 Expected Output : 4 i wrote this code but there are wornings.. what is wrong here ?? double input; int x=input; // so x=the integeral part of input int y=input-x; // so y=the fractional part while(y>0) {count++; input*=10; x=input; y=input-x; } plz help me !! elmahdy
-
how to get the number of digits after the decimal point ex : Input : 5.1234 Expected Output : 4 i wrote this code but there are wornings.. what is wrong here ?? double input; int x=input; // so x=the integeral part of input int y=input-x; // so y=the fractional part while(y>0) {count++; input*=10; x=input; y=input-x; } plz help me !! elmahdy
-
how to get the number of digits after the decimal point ex : Input : 5.1234 Expected Output : 4 i wrote this code but there are wornings.. what is wrong here ?? double input; int x=input; // so x=the integeral part of input int y=input-x; // so y=the fractional part while(y>0) {count++; input*=10; x=input; y=input-x; } plz help me !! elmahdy
I'm guessing there are a lot of ways to do this. How about this! double input; int Num = static_cast< int >( input ); intput -= static_cast< double >( Num ); You should now just have the .XXXX Char szData[1024]; ssprintf( szData, "%f", &Input ); int iLengt = strlen( szData ) - 2; //For the zero & the '.' This can give you a start. Larry J. Siddens Cornerstone Communications TAME THE DOCUMENT MONSTER www.unifier.biz