Error With HDPM01 I2C Interfacing

Hello,
I'm new here. I'm trying to interface with HDPM01 Barometer/Compass module and I'm getting "-1" all of the time from the compass sensor.
This is the datasheet of the HDPM01 module:
http://www.hoperf.com/upload/sensor/HDPM01.pdf
This is the code I have written for getting angle:

#include<Wire.h>
#include<math.h>
void setup()
{
  Serial.begin(9600);
  Wire.begin();
}
void loop()
{
  int i=0;
  Wire.beginTransmission(50);
  Wire.write(0);
  Wire.write(1);
  Wire.endTransmission(50);
  delay(10);
  Wire.beginTransmission(50);
  Wire.write(0);
  int array[5];
  for(i=0;i<5;i++)
  {
    Wire.requestFrom(50,1);
    while(Wire.available()==0);
    array[i]=Wire.read();
  }
  array[1]=array[1]<<8;
  array[3]=array[3]<<8;
  int x=array[1]|array[2];
  int y=array[3]|array[4];
  float angle=atan(y/x);
  Serial.println(angle);
  delay(500);
}

Can someone help me with this and with the Barometer sensor reading data code from it?

This is the manufacturer page for it: http://www.hoperf.com/sensor/app/hdpm01.htm
I don't know if your code is according to the programming guide.

Did you connect it like this ?
Arduino GND to GND
Arduino 3.3V to VDD
Arduino SDA to SDA (not for a Arduino Mega 2560)
Arduino SCL to SCL (not for a Arduino Mega 2560)
XCLR needs to be set high and low during operation. You can use an output pin of the Arduino with two resistors as a voltage divider.
MCLK needs to be 32768 kHz. So you have to make that with the Arduino and again using a voltage divider.

If you have all that, you can run the i2c_scanner to see if the sensor is on the I2C bus:
http://playground.arduino.cc/Main/I2cScanner

Why do you want to use this strange freaky outdated sensor ? There are many cheaper and better sensors that are easier to connect to the Arduino with libraries and so on.