#include <stdio.h>

long Q30(float f)
{
  return (long)(f * (float)(1<<30));
}

long q30_mul(long a, long b)
{
  long long ab = a * b;
  return (long)(ab>>30LL);
}

int asin_fp(long x)
{
  int y;
  y = Q30(1.5) - (x>>1);  // y1 = 3/2 - 1/2*x
  y = q30_mul( Q30(1.5) - q30_mul( x, q30_mul(y,y>>1) ) , y ); // y2 = (1.5 - x * y1* (y1/2) ) * y1

  return y;
}

int main(int argc, char **argv) {
  int angle;
  fprintf(stdout, "%f %lx\n", 1.0, Q30(1.0));
  fprintf(stdout, "%f %lx\n", 0.5, Q30(0.5));
  fprintf(stdout, "%f %lx\n", 0.0, Q30(0.0));
  fprintf(stdout, "%f %lx\n", -0.5, Q30(-0.5));
  fprintf(stdout, "%f %lx\n", -1.0, Q30(-1.0));

  return 0;
}
