Fixed: calculator behavior for negative values in trigonometric functions

This commit is contained in:
Markus Gans 2015-10-17 05:13:14 +02:00
parent 78a1c0cb85
commit 2b3a7d3a4c
5 changed files with 41 additions and 36 deletions

View File

@ -1,3 +1,7 @@
2015-10-16 Markus Gans <guru.mail@muenster.de>
* Fixed: calculator behavior for negative values
in trigonometric functions
2015-10-13 Markus Gans <guru.mail@muenster.de> 2015-10-13 Markus Gans <guru.mail@muenster.de>
* Reduce the number of getParent() function calls for print operations * Reduce the number of getParent() function calls for print operations

View File

@ -116,7 +116,7 @@ void FButton::setHotkeyAccelerator()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::detectHotkey() inline void FButton::detectHotkey()
{ {
if ( isEnabled() ) if ( isEnabled() )
{ {

View File

@ -1921,7 +1921,7 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::isCovered(const FPoint& pos, FTerm::term_area* area) const inline bool FTerm::isCovered(const FPoint& pos, FTerm::term_area* area) const
{ {
if ( area == 0 ) if ( area == 0 )
return false; return false;
@ -2085,7 +2085,7 @@ void FTerm::setUpdateVTerm (bool on)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::getArea (const FPoint& pos, FTerm::term_area* area) inline void FTerm::getArea (const FPoint& pos, FTerm::term_area* area)
{ {
if ( area == 0 ) if ( area == 0 )
return; return;
@ -2129,7 +2129,7 @@ void FTerm::getArea (int ax, int ay, FTerm::term_area* area)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::getArea (const FRect& box, FTerm::term_area* area) inline void FTerm::getArea (const FRect& box, FTerm::term_area* area)
{ {
getArea ( box.getX() getArea ( box.getX()
, box.getY() , box.getY()
@ -2251,7 +2251,7 @@ void FTerm::putArea (int ax, int ay, FTerm::term_area* area)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTerm::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj) inline FTerm::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj)
{ {
return getCoveredCharacter (pos.getX(), pos.getY(), obj); return getCoveredCharacter (pos.getX(), pos.getY(), obj);
} }
@ -2316,7 +2316,7 @@ FTerm::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj)
// public methods of FTerm // public methods of FTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTerm::term_area* FTerm::getVWin() const inline FTerm::term_area* FTerm::getVWin() const
{ {
return vwin; return vwin;
} }
@ -4129,14 +4129,14 @@ int FTerm::appendLowerRight (char_data*& screen_char)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::appendOutputBuffer (std::string& s) inline void FTerm::appendOutputBuffer (std::string& s)
{ {
const char* c_string = s.c_str(); const char* c_string = s.c_str();
tputs (c_string, 1, appendOutputBuffer); tputs (c_string, 1, appendOutputBuffer);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::appendOutputBuffer (const char* s) inline void FTerm::appendOutputBuffer (const char* s)
{ {
tputs (s, 1, appendOutputBuffer); tputs (s, 1, appendOutputBuffer);
} }
@ -4178,7 +4178,7 @@ void FTerm::putstringf (const char* format, ...)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::putstring (const char* s, int affcnt) inline void FTerm::putstring (const char* s, int affcnt)
{ {
tputs (s, affcnt, putchar); tputs (s, affcnt, putchar);
} }

View File

@ -182,7 +182,7 @@ void FWidget::finish()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::processDestroy() inline void FWidget::processDestroy()
{ {
emitCallback("destroy"); emitCallback("destroy");
} }
@ -308,7 +308,7 @@ void FWidget::setColorTheme()
wc.label_hotkey_fg = fc::Red; wc.label_hotkey_fg = fc::Red;
wc.label_hotkey_bg = fc::LightGray; wc.label_hotkey_bg = fc::LightGray;
wc.label_emphasis_fg = fc::Blue; wc.label_emphasis_fg = fc::Blue;
wc.label_ellipsis_fg = fc::DarkGray; wc.label_ellipsis_fg = fc::Black;
wc.inputfield_active_focus_fg = fc::LightGray; wc.inputfield_active_focus_fg = fc::LightGray;
wc.inputfield_active_focus_bg = fc::Blue; wc.inputfield_active_focus_bg = fc::Blue;
wc.inputfield_active_fg = fc::Black; wc.inputfield_active_fg = fc::Black;
@ -338,7 +338,7 @@ void FWidget::setColorTheme()
wc.menu_active_focus_bg = fc::Blue; wc.menu_active_focus_bg = fc::Blue;
wc.menu_active_fg = fc::Black; wc.menu_active_fg = fc::Black;
wc.menu_active_bg = fc::LightGray; wc.menu_active_bg = fc::LightGray;
wc.menu_inactive_fg = fc::DarkGray; wc.menu_inactive_fg = fc::Cyan;
wc.menu_inactive_bg = fc::LightGray; wc.menu_inactive_bg = fc::LightGray;
wc.menu_hotkey_fg = fc::Red; wc.menu_hotkey_fg = fc::Red;
wc.menu_hotkey_bg = fc::LightGray; wc.menu_hotkey_bg = fc::LightGray;
@ -387,7 +387,7 @@ FTerm::term_area* FWidget::getPrintArea()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPrintArea(term_area* area) inline void FWidget::setPrintArea(term_area* area)
{ {
print_area = area; print_area = area;
} }
@ -826,21 +826,21 @@ FWidget* FWidget::getRootWidget() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::getMainWidget() inline FWidget* FWidget::getMainWidget()
{ {
FWidget* main_widget = static_cast<FWidget*>(FApplication::main_widget); FWidget* main_widget = static_cast<FWidget*>(FApplication::main_widget);
return main_widget; return main_widget;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setMainWidget(FWidget* obj) inline void FWidget::setMainWidget(FWidget* obj)
{ {
FApplication* fapp = static_cast<FApplication*>(rootObject); FApplication* fapp = static_cast<FApplication*>(rootObject);
fapp->setMainWidget(obj); fapp->setMainWidget(obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos) inline FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos)
{ {
return childWidgetAt (p, pos.getX(), pos.getY()); return childWidgetAt (p, pos.getX(), pos.getY());
} }
@ -875,27 +875,27 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::getFocusWidget() const inline FWidget* FWidget::getFocusWidget() const
{ {
FWidget* focus_widget = static_cast<FWidget*>(FApplication::focus_widget); FWidget* focus_widget = static_cast<FWidget*>(FApplication::focus_widget);
return focus_widget; return focus_widget;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setFocusWidget(FWidget* obj) inline void FWidget::setFocusWidget(FWidget* obj)
{ {
FApplication::focus_widget = obj; FApplication::focus_widget = obj;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::getClickedWidget() inline FWidget* FWidget::getClickedWidget()
{ {
FWidget* clicked_widget = static_cast<FWidget*>(FApplication::clicked_widget); FWidget* clicked_widget = static_cast<FWidget*>(FApplication::clicked_widget);
return clicked_widget; return clicked_widget;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setClickedWidget(FWidget* obj) inline void FWidget::setClickedWidget(FWidget* obj)
{ {
FApplication::clicked_widget = obj; FApplication::clicked_widget = obj;
} }
@ -1331,13 +1331,13 @@ void FWidget::hide()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setEnable(bool on) inline bool FWidget::setEnable(bool on)
{ {
return enable = (on) ? true : false; return enable = (on) ? true : false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setVisibleCursor(bool on) inline bool FWidget::setVisibleCursor(bool on)
{ {
return visibleCursor = (on) ? true : false; return visibleCursor = (on) ? true : false;
} }
@ -1514,7 +1514,7 @@ void FWidget::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPos (const FPoint& p, bool adjust) inline void FWidget::setPos (const FPoint& p, bool adjust)
{ {
setPos (p.getX(), p.getY(), adjust); setPos (p.getX(), p.getY(), adjust);
} }
@ -1669,7 +1669,7 @@ void FWidget::setTermGeometry (int w, int h)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setGeometry (const FRect& box, bool adjust) inline void FWidget::setGeometry (const FRect& box, bool adjust)
{ {
setGeometry ( box.getX() setGeometry ( box.getX()
, box.getY() , box.getY()
@ -1721,7 +1721,7 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::move (const FPoint& pos) inline void FWidget::move (const FPoint& pos)
{ {
move( pos.getX(), pos.getY() ); move( pos.getX(), pos.getY() );
} }
@ -1779,19 +1779,19 @@ bool FWidget::setCursorPos (register int x, register int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::unsetCursorPos() inline void FWidget::unsetCursorPos()
{ {
widgetCursorPosition.setPoint(-1,-1); widgetCursorPosition.setPoint(-1,-1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::gotoxy (const FPoint& pos) inline void FWidget::gotoxy (const FPoint& pos)
{ {
gotoxy (pos.getX(), pos.getY()); gotoxy (pos.getX(), pos.getY());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::gotoxy (register int x, register int y) inline void FWidget::gotoxy (register int x, register int y)
{ {
cursor->setPoint(x,y); cursor->setPoint(x,y);
} }
@ -1842,19 +1842,19 @@ void FWidget::clrscr()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setBold (register bool on) inline bool FWidget::setBold (register bool on)
{ {
return (bold = on); return (bold = on);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setReverse (register bool on) inline bool FWidget::setReverse (register bool on)
{ {
return (reverse = on); return (reverse = on);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setUnderline (register bool on) inline bool FWidget::setUnderline (register bool on)
{ {
return (underline = on); return (underline = on);
} }
@ -2264,7 +2264,7 @@ void FWidget::drawBorder()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::quit() inline void FWidget::quit()
{ {
FApplication* fapp = static_cast<FApplication*>(rootObject); FApplication* fapp = static_cast<FApplication*>(rootObject);
fapp->exit(0); fapp->exit(0);

View File

@ -582,7 +582,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
{ {
if ( arcus_mode ) if ( arcus_mode )
*x = asin(*x) * 180.0L/PI; *x = asin(*x) * 180.0L/PI;
else if ( fmod(*x,180.0L) < LDBL_EPSILON ) // x/180 = 0 else if ( fabs(fmod(*x,180.0L)) < LDBL_EPSILON ) // x/180 = 0
*x = 0.0L; *x = 0.0L;
else else
*x = sin(*x * PI/180.0L); *x = sin(*x * PI/180.0L);
@ -614,7 +614,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
{ {
if ( arcus_mode ) if ( arcus_mode )
*x = acos(*x) * 180.0L/PI; *x = acos(*x) * 180.0L/PI;
else if ( fmod(*x - 90.0L,180.0L) < LDBL_EPSILON ) // (x - 90)/180 == 0 else if ( fabs(fmod(*x - 90.0L,180.0L)) < LDBL_EPSILON ) // (x - 90)/180 == 0
*x = 0.0L; *x = 0.0L;
else else
*x = cos(*x * PI/180.0L); *x = cos(*x * PI/180.0L);
@ -649,9 +649,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
*x = atan(*x) * 180.0L/PI; *x = atan(*x) * 180.0L/PI;
else else
// Test if (x/180) != 0 and x/90 == 0 // Test if (x/180) != 0 and x/90 == 0
if ( fmod(*x,180.0L) > LDBL_EPSILON && fmod(*x,90.0L) < LDBL_EPSILON ) if ( fabs(fmod(*x,180.0L)) > LDBL_EPSILON
&& fabs(fmod(*x,90.0L)) < LDBL_EPSILON )
error = true; error = true;
else if ( fmod(*x,180.0L) < LDBL_EPSILON ) // x/180 == 0 else if ( fabs(fmod(*x,180.0L)) < LDBL_EPSILON ) // x/180 == 0
*x = 0.0L; *x = 0.0L;
else else
*x = tan(*x * PI/180.0L); *x = tan(*x * PI/180.0L);