In creating trig functions
my_tand(d), that used a degree argument rather than a radian one and provided exact answers at multiples of 90, I noticed that the result was sometimes
-0.0 rather than
my_sind( 0.0) --> 0.0 my_sind(-0.0) --> -0.0 my_sind(180.0) --> -0.0 my_sind(360.0) --> 0.0
tan() typically return the same sign zero result for a given sign zero input. It makes sense that
my_sin() should match
sin() for those inputs.
my_sind( 0.0) alike sin( 0.0) --> 0.0 my_sind(-0.0) alike sin(-0.0) --> -0.0
The question is: for what whole number
non_zero_n should/may the result ever return
my_cosd(180*n + 180),
It is easy enough to code so only
-0.0 and be done with it. Simple wondering if there is any reason to make
-0.0 for any other (non-zero)
x and the importance of insuring that sign.
Note: This is not a question of why
-0.0 occurs. This is not why
cos(machine_pi/4) does not return
0.0. Neither is this a question of how to control the generation of
-0.0. I see it best as a design question.