OK, I *definitely* need a remedial math class...

Now compute number of digits required using B / A, and then looping.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2264 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet
2002-05-28 00:16:08 +00:00
parent c9c0c7a298
commit 465d6f914a
+4 -4
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Valuator.cxx,v 1.5.2.4.2.3 2002/05/28 00:12:49 easysw Exp $"
// "$Id: Fl_Valuator.cxx,v 1.5.2.4.2.4 2002/05/28 00:16:08 easysw Exp $"
//
// Valuator widget for the Fast Light Tool Kit (FLTK).
//
@@ -117,11 +117,11 @@ int Fl_Valuator::format(char* buffer) {
double v = value();
if (!A) return sprintf(buffer, "%g", v);
int i, x;
double ab = A * B;
for (x = 1, i = 0; x < ab; x *= 10) i++;
double ba = B / A;
for (x = 1, i = 0; x < ba; x *= 10) i++;
return sprintf(buffer, "%.*f", i, v);
}
//
// End of "$Id: Fl_Valuator.cxx,v 1.5.2.4.2.3 2002/05/28 00:12:49 easysw Exp $".
// End of "$Id: Fl_Valuator.cxx,v 1.5.2.4.2.4 2002/05/28 00:16:08 easysw Exp $".
//