atan2 function problem in db2,java,javascript

Last day I was working on a formula to calculate the bearing(and finally direction from point 1 to point 2). I was using the formula described here. I was running same formula in java as well as DB2. But getting different result. After much analysis I found the problem with the atan2 API in DB2 and Java.

Java API accept y and x as first and second argument where as DB2 API accepts in reverse order.  I also found that  java script also accept y argument first. This is quite bad. I don’t know which one is right but everyone should follow same pattern. This difference in API was the source of the bug.

During this analysis I also found that Db2 client(squirrel) was not returning the precise value where as Db2 client was returning. sqirrel_db2

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s