From c6518823c465f50dd61691a4984de32a87c42633 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 22 Jun 2015 02:01:50 +0200 Subject: [PATCH] Improve trigonometric function zero-crossing --- test/calculator.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/calculator.cpp b/test/calculator.cpp index 3011fe5b..da5c3b68 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -565,6 +565,8 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) { if ( arcus_mode ) *x = asin(*x) * 180.0L/PI; + else if ( fmod(*x,180.0L) == 0.0L ) + *x = 0.0L; else *x = sin(*x * PI/180.0L); } @@ -595,6 +597,8 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) { if ( arcus_mode ) *x = acos(*x) * 180.0L/PI; + else if ( fmod(*x - 90.0L,180.0L) == 0.0L ) + *x = 0.0L; else *x = cos(*x * PI/180.0L); }