Nicolai Rosen on Sat, 20 Nov 1999 15:07:50 -0500 (EST) |
The problem is that you're assuming that pow(10,a) raises 10 to the ath power the same way you or I would. It doesn't. As a result, you get an answer that is slightly off. Ordinarily this wouldn't matter, but because you're trying to get an exact integer answer. I'd reccomend making your own function for that. Make something like: float lower10(int power){ float result=1; for(;power<0;power++) result/=10; return result; } Oh, & as an aside, if you want to return the number of decimal places, shouldn't that be -a? From: Morgan Wajda-Levie <mpwl@locke.ccil.org> Reply-To: plug@lists.nothinbut.net To: Plug <plug@lists.nothinbut.net> Subject: [Plug] Strange floating point behavior with C++ Date: Sat, 20 Nov 1999 14:52:56 -0500
_______________________________________________ Plug maillist - Plug@lists.nothinbut.net http://lists.nothinbut.net/mail/listinfo/plug
|
|