Re: Proposal: Trigonometric functions in degrees - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Proposal: Trigonometric functions in degrees
Date
Msg-id CAEZATCXRWw9qnWFMrh-B+gbNuVNG3HKgpHgTY1kZ=OhdoGE1Wg@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: Trigonometric functions in degrees  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Proposal: Trigonometric functions in degrees
List pgsql-hackers
On 26 October 2015 at 19:45, Peter Eisentraut <peter_e@gmx.net> wrote:
> On 10/24/15 5:24 AM, Dean Rasheed wrote:
>> Additionally, functions that worked natively in degrees would be able
>> to return exact answers in special cases like cosd(90) = 0, whereas
>> cos(radians(90)) is not exactly 0 because pi/2 cannot be represented
>> exactly as a floating point number.
>
> But how you are going to implement that?  I don't see a sind() in the C
> library.
>

I'm thinking something along the lines of:

1. Reduce the range of the input (say to 0..90 degrees).
2. Handle special cases (0, 30 and 90 for sind()).
3. Otherwise convert to radians for the general case.

Regards,
Dean



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Proposal: Trigonometric functions in degrees
Next
From: Tom Lane
Date:
Subject: Re: Proposal: Trigonometric functions in degrees