diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2002-05-21 16:50:48 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2002-05-21 16:50:48 +0000 |
| commit | dc560e83e39cad62c6583d74b9d84c6eda98d1f6 (patch) | |
| tree | 8f8a2abdffef78f0cd1db4f0393afd5a91c95408 /src/Fl_Value_Input.cxx | |
| parent | 23cfc372a0dab95c688190f49614c1b9090cc435 (diff) | |
Use floor() instead of trunc() when checking if step() is an integer
(it is equivalent to trunc() for positive numbers)
Fix order of subtraction so that the test actually works right.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2247 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Value_Input.cxx')
| -rw-r--r-- | src/Fl_Value_Input.cxx | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/Fl_Value_Input.cxx b/src/Fl_Value_Input.cxx index 0fefb7694..2cbfc83e2 100644 --- a/src/Fl_Value_Input.cxx +++ b/src/Fl_Value_Input.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.4 2002/05/21 11:14:59 easysw Exp $" +// "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.5 2002/05/21 16:50:48 easysw Exp $" // // Value input widget for the Fast Light Tool Kit (FLTK). // @@ -33,15 +33,11 @@ #include <stdlib.h> #include <FL/math.h> -// Some math headers don't seem to define this function... -extern "C" { - double trunc(double); -} void Fl_Value_Input::input_cb(Fl_Widget*, void* v) { Fl_Value_Input& t = *(Fl_Value_Input*)v; double nv; - if ((trunc(t.step()) - t.step())>0.0) nv = strtod(t.input.value(), 0); + if ((t.step() - floor(t.step()))>0.0) nv = strtod(t.input.value(), 0); else nv = strtol(t.input.value(), 0, 0); if (nv != t.value() || t.when() & FL_WHEN_NOT_CHANGED) { t.set_value(nv); @@ -114,7 +110,7 @@ int Fl_Value_Input::handle(int event) { return input.take_focus(); default: DEFAULT: - input.type((trunc(step()) - step())>0.0 ? FL_FLOAT_INPUT : FL_INT_INPUT); + input.type((step() - floor(step()))>0.0 ? FL_FLOAT_INPUT : FL_INT_INPUT); return input.handle(event); } } @@ -135,5 +131,5 @@ Fl_Value_Input::Fl_Value_Input(int x, int y, int w, int h, const char* l) } // -// End of "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.4 2002/05/21 11:14:59 easysw Exp $". +// End of "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.5 2002/05/21 16:50:48 easysw Exp $". // |
