mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 03:15:21 +08:00
Fix overflow in Fl_Valuator::precision(int) to 0...9 (STR #3280).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11317 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+12
-3
@@ -51,10 +51,19 @@ void Fl_Valuator::step(double s) {
|
|||||||
while (fabs(s-A/B) > epsilon && B<=(0x7fffffff/10)) {B *= 10; A = rint(s*B);}
|
while (fabs(s-A/B) > epsilon && B<=(0x7fffffff/10)) {B *= 10; A = rint(s*B);}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the step value to 1/10<SUP>digits</SUP>.*/
|
/** Sets the step value to 1.0 / 10<SUP>digits</SUP>.
|
||||||
void Fl_Valuator::precision(int p) {
|
|
||||||
|
Precision \p digits is limited to 0...9 to avoid internal overflow errors.
|
||||||
|
Values outside this range are clamped.
|
||||||
|
|
||||||
|
\note For negative values of \p digits the step value is set to
|
||||||
|
\p A = 1.0 and \p B = 1, i.e. 1.0/1 = 1.
|
||||||
|
*/
|
||||||
|
void Fl_Valuator::precision(int digits) {
|
||||||
|
if (digits > 9) digits = 9;
|
||||||
|
else if (digits < 0) digits = 0;
|
||||||
A = 1.0;
|
A = 1.0;
|
||||||
for (B = 1; p--;) B *= 10;
|
for (B = 1; digits--;) B *= 10;
|
||||||
}
|
}
|
||||||
/** Asks for partial redraw */
|
/** Asks for partial redraw */
|
||||||
void Fl_Valuator::value_damage() {damage(FL_DAMAGE_EXPOSE);} // by default do partial-redraw
|
void Fl_Valuator::value_damage() {damage(FL_DAMAGE_EXPOSE);} // by default do partial-redraw
|
||||||
|
|||||||
Reference in New Issue
Block a user