All pastes #498867 Raw Edit

Chao7

public text v1 · immutable
·published 2007-05-20 18:47 UTC
rendered paste body
const float cPi = 3.14159265; // 3.14159274
const float4 ePi = float4(
  //3.14159265358979323846264338327950288419716939937510
    3.141592503e-0,
  //3.141592503 - 7dp
          0.1505897842e-6,
  //3.1415926535897842 - 14 dp
                  0.9038462422e-014,
  //3.141592653589793238462422 - 21 dp
                         0.2213832739e-021
  //3.1415926535897932384626433832739 - 29 dp
);
 
 
#ifndef PI_PRECISION
#define PI_PRECISION 0
#endif
 
#if PI_PRECISION == 0
const float getPi() {
    return cPi;
}
 
#elif PI_PRECISION == 29 
const float getPi() {
    float rPi;
    rPi = ePi[3] +
          ePi[2] +
          ePi[1] +
          ePi[0] ;
    return rPi;
}
#elif PI_PRECISION == 21 
const float getPi() {
    float rPi;
    rPi = ePi[2] +
          ePi[1] +
          ePi[0] ;
    return rPi;
}
#elif PI_PRECISION == 14
const float getPi() {
    volatile float rPi;
    rPi = ePi[1] +
          ePi[0] ;
    return rPi;
}
#endif

const static float Pi = getPi();

float4 main( float4 unk1 : COLOR1, float4 unk2 : COLOR2 ) : COLOR0 {
    // arguments to main are 'uncertain', and so are not const-expression optimized away
    return float4( Pi, Pi, Pi, Pi );
}