public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Deviations in _Sinh(double, double); and the related functions.
@ 2003-11-22 23:37 Dara Hazeghi
  0 siblings, 0 replies; 2+ messages in thread
From: Dara Hazeghi @ 2003-11-22 23:37 UTC (permalink / raw)
  To: Pavan.Amancherla; +Cc: gcc-help

Hello,

given that your code doesn't compile as-is with gcc
3.3 and libstdc++, I suspect your problem is with the
dinkumware library, and you should tell them.

Dara

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Deviations in _Sinh(double, double); and the related functions.
@ 2003-11-18 14:58 Pavan, Amancherla (IE10)
  0 siblings, 0 replies; 2+ messages in thread
From: Pavan, Amancherla (IE10) @ 2003-11-18 14:58 UTC (permalink / raw)
  To: gcc-help

The following functions are giving wrong results for some of the inputs on
gcc_ppc compiler with Dinkumware library.
double _Sinh(double, double);
float _FSinh(float, float);
long double _LSinh(long double, long double);
These are declared in <ymath.h> in Dinkumware library.

These functions are supposed to behave as follows
_Sinh(a, b) = sinh(a) * b

But when the value of the the first argument('a') is in between [-0.55, 0)
or (0, 0.55]
I am getting wrong results.
_Sinh(a, b) is returning a value equal to sinh(a), what ever may be the
second argument, for the above range of values.
For zero and values very near to it(like 0.00000013) and other values, I am
getting right results.


Here is the sample code.

#include <ymath.h>
#include <iostream>
#include <cmath>

using namespace std;
void verify(char * comment_string, double actual_value, double
expected_value)
{
	
cout<<comment_string<<"\t\t"<<actual_value<<"\t\t"<<expected_value<<endl;
}

void main()
{
	for(double value = -0.6; (value <= 0.6); value += 0.01)
	{
		cout<<"Angle  : "<<value<<endl;
		verify("_Sinh with second arg as -1.2", 
			_Sinh(value, -1.2), std::sinh(value) * -1.2);
		verify("_Sinh with second arg as -1.0", 
			_Sinh(value, -1.0), std::sinh(value) * -1.0);
		verify("_Sinh with second arg as -0.9", 
			_Sinh(value, -0.9), std::sinh(value) * -0.9);
		verify("_Sinh with second arg as -0.2", 
			_Sinh(value, -0.2), std::sinh(value) * -0.2);
		verify("_Sinh with second arg as 0.0", 
			_Sinh(value, 0.0), std::sinh(value) * 0.0);
		verify("_Sinh with second arg as 0.2", 
			_Sinh(value, 0.2), std::sinh(value) * 0.2);
		verify("_Sinh with second arg as 0.9", 
			_Sinh(value, 0.9), std::sinh(value) * 0.9);
		verify("_Sinh with second arg as 1.0", 
			_Sinh(value, 1.0), std::sinh(value) * 1.0);
		verify("_Sinh with second arg as 1.2", 
			_Sinh(value, 1.2), std::sinh(value) * 1.2);
	}
	verify("_Sinh for a value very near to zero", 
		_Sinh(value, 0.00000013), std::sinh(value) * 0.00000013);
}

Observe that when the values for 'a' for _Sinh(a, b) are in the range [-0.6,
-0.55] the results are correct,
for [-0.55, 0.55] results are wrong(except for zero),
for [0.55, 0.6] the results are correct.
Can you please tell me if my observation is correct and why this is
happening like this.

Thanks,
pavan.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-22 23:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-22 23:37 Deviations in _Sinh(double, double); and the related functions Dara Hazeghi
  -- strict thread matches above, loose matches on Subject: below --
2003-11-18 14:58 Pavan, Amancherla (IE10)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).