Beispiel #1
0
int float_age(float x, float y){
    unsigned ux = f2u(x);
    unsigned uy = f2u(y);

    // Get the sign bits
    unsigned sx = ux >> 31;
    unsigned sy = uy >> 31;

    // using only ux, uy, sx, sy
    return (
                (!(sx^sy))
                    &&
                (
                    (
                        (!sx) && ((ux>uy))
                    )
                    ||
                    (
                        (!!sx) && (!!(ux<uy))
                    )
                )
            )
            ||
            (
                (sx^sy)
                    &&
                (
                    (ux<<1)^(uy<<1)
                        &&
                    !sx
                )
            );
}
Beispiel #2
0
void print_fpwr2(int x)
{
	float f1 = fpw2(x);
	float f2 = fpwr2_check(x);
	if (f1 != f2) {
		printf("x = %d, f1 = %10.20f, f2 = %10.20f\r\n", x, f1, f2);
		printf("\t\t%u, %u\r\n", f2u(f1), f2u(f2));	
		assert(0);
	}
}
Beispiel #3
0
int float_ge(float x, float y)
{
    unsigned ux = f2u(x);
    unsigned uy = f2u(y);
    unsigned sx = ux>>31;
    unsigned sy = uy>>31;
    return 	(  sx &&  sy ) && (ux <= uy)	|| //x<=0,y<=0
            (  sx && !sy) && (ux == INT_MIN && uy == 0)	||  //x<=0,y>=0
            ( !sx &&  sy) ||		// x>=0, y<=0
            ( !sx &&  sy) && (ux>=uy); // x>=0, y>=0
}
Beispiel #4
0
int float_ge(float x, float y) {
    unsigned ux = f2u(x);
    unsigned uy = f2u(y);
    unsigned sx = ux >> 31;
    unsigned sy = uy >> 31;
    /*
    如果符号位都为正数的情况下,那么exponent filed比较大的数,那么数值就会比较大,因为fraction field代表的值为1.*,小数右移一位一定比分数部分的和要大
    如果exponent filed的值相同,那就比较fraction field的值就可以确定大小,如果都相同那么就相等。
    那么如果符号位的值不全为正数的情况下呢?
    如果一正一负:那么值更大的那个一定为负数。
    如果两个负数:那么值更大的那一个一定为更小的值。因为在float point中exponent filed和fraction field的值越大,符号位为1,值就越小。
    所以总结出在符号位不全为正的情况下,更大的那一个一定是最小的,所以!(ux > uy),指ux>uy的时候一定x比y小,当ux<=uy的时候,x则大于等于y.
    */
    return (sx > 0 && sy > 0) ? (ux >= uy) : !(ux > uy);
}
unsigned test_float_neg(unsigned uf) {
    float f = u2f(uf);
    float nf = -f;
    if (isnan(f))
 return uf;
    else
 return f2u(nf);
}
Beispiel #6
0
unsigned test_float_twice(unsigned uf) {
  float f = u2f(uf);
  float tf = 2*f;
  if (isnan(f))
    return uf;
  else
    return f2u(tf);
}
Beispiel #7
0
unsigned test_float_times64(unsigned uf) {
  float f = u2f(uf);
  float tenf = 64*f;
  if (isnan(f))
    return uf;
  else
    return f2u(tenf);
}
unsigned test_float_times_four(unsigned uf) {
  float f = u2f(uf);
  float tf = 4*f;
  if (isnan(f))
    return uf;
  else
    return f2u(tf);
}
unsigned test_float_half_denorm(unsigned uf) {
  float f = u2f(uf);
  float hf = 0.5*f;
  if(uf&0x7f800000)
    return uf;
  else
    return f2u(hf);
}
Beispiel #10
0
unsigned test_float_half(unsigned uf) {
  float f = u2f(uf);
  float hf = 0.5*f;
  if (isnan(f))
    return uf;
  else
    return f2u(hf);
}
Beispiel #11
0
static void opCVTW(void)
{
	//TODO: CY
	float val1=GETREG(GET1);
	SET_OV(0);
	SET_Z((val1==0.0)?1:0);
	SET_S((val1<0.0)?1:0);
	SETREG(GET2,f2u(val1));
}
Beispiel #12
0
static void opMULF(void)
{
	//TODO: CY
	float val1=u2f(GETREG(GET1));
	float val2=u2f(GETREG(GET2));
	SET_OV(0);
	val2*=val1;
	SET_Z((val2==0.0)?1:0);
	SET_S((val2<0.0)?1:0);
	SETREG(GET2,f2u(val2));
}
Beispiel #13
0
static void opSUBF(void)
{
	float val1=u2f(GETREG(GET1));
	float val2=u2f(GETREG(GET2));
	SET_OV(0);
	SET_CY((val2<val1)?1:0);
	val2-=val1;
	SET_Z((val2==0.0)?1:0);
	SET_S((val2<0.0)?1:0);
	SETREG(GET2,f2u(val2));
}
static void
tstmul (unsigned int ux, unsigned int uy, unsigned int ur)
{
	float x = u2f (ux);
	float y = u2f (uy);

	if (f2u (x * y) != ur)
	/* Set a variable rather than aborting here, to simplify tracing when
	   several computations are wrong.  */
		ok = 0;
}
Beispiel #15
0
unsigned test_float_abs(unsigned uf) {
  float f = u2f(uf);
  unsigned unf = f2u(-f);
  if (isnan(f))
    return uf;
  /* An unfortunate hack to get around a limitation of the BDD Checker */
  if ((int) uf < 0)
      return unf;
  else
      return uf;
}
Beispiel #16
0
/* $begin floatge-template */
int float_ge(float x, float y) 
{ 
    unsigned ux = f2u(x); 
    unsigned uy = f2u(y); 

    /* Get the sign bits */ 
    unsigned sx = ux >> 31; 
    unsigned sy = uy >> 31; 

/* $end floatge-template */
#if 0
/* $begin floatge-template */
    /* Give an expression using only ux, uy, sx, and sy */
    return /* ... */ ;
/* $end floatge-template */
#endif

    return sx+sy; /* just to keep gcc happy */

/* $begin floatge-template */
} 
Beispiel #17
0
static void opDIVF(void)
{
	//TODO: CY
	float val1=u2f(GETREG(GET1));
	float val2=u2f(GETREG(GET2));
	SET_OV(0);
	if(val1!=0)
		val2/=val1;
	SET_Z((val2==0.0)?1:0);
	SET_S((val2<0.0)?1:0);
	SETREG(GET2,f2u(val2));
}
Beispiel #18
0
int main(void)
{
    float f;
    unsigned u, t;

    int i = INT_MIN;
    do {
        f = (float) i;
        u = f2u(f);
        t = float_i2f(i);
        if (u != t)
            printf("BAD: 0x%X, 0x%X, 0x%X\n", t, i, u);
    } while (i++ != INT_MAX);

    return 0;
}
Beispiel #19
0
static UINT32 opNEGFS(v60_state *cpustate)
{
	float appf;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);
	F2DecodeSecondOperand(cpustate, ReadAMAddress, 2);

	appf = -u2f(cpustate->op1);

	cpustate->_OV = 0;
	cpustate->_CY = (appf < 0.0f);
	cpustate->_S = ((f2u(appf) & 0x80000000) != 0);
	cpustate->_Z = (appf == 0.0f);

	F2STOREOPFLOAT(cpustate, 2);
	F2END(cpustate)
}
Beispiel #20
0
int opNEGFS(void)
{
	float appf;

	F2DecodeFirstOperand(ReadAM, 2);
	F2DecodeSecondOperand(ReadAMAddress, 2);

	appf = -u2f(f2Op1);

	_OV=0;
	_CY=(appf < 0.0f);
	_S=((f2u(appf) & 0x80000000)!=0);
	_Z=(appf == 0.0f);

	F2STOREOPFLOAT(2);
	F2END()
}
Beispiel #21
0
static UINT32 opCVTWS(v60_state *cpustate)
{
	float val;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);

	// Convert to float
	val = (float)(INT32)cpustate->op1;
	cpustate->modwritevalw = f2u(val);

	cpustate->_OV = 0;
	cpustate->_CY = (val < 0.0f);
	cpustate->_S = ((cpustate->modwritevalw & 0x80000000) != 0);
	cpustate->_Z = (val == 0.0f);

	F2WriteSecondOperand(cpustate, 2);
	F2END(cpustate);
}
Beispiel #22
0
int opCVTWS(void)
{
	float val;

	F2DecodeFirstOperand(ReadAM,2);

	// Convert to float
	val = (float)(INT32)f2Op1;
	modWriteValW = f2u(val);

	_OV=0;
	_CY=(val < 0.0f);
	_S=((modWriteValW & 0x80000000)!=0);
	_Z=(val == 0.0f);

	F2WriteSecondOperand(2);
	F2END();
}
Beispiel #23
0
static UINT32 opDIVFS(v60_state *cpustate)
{
	UINT32 appw;
	float appf;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);
	F2DecodeSecondOperand(cpustate, ReadAMAddress, 2);

	F2LOADOPFLOAT(cpustate, 2);

	appf /= u2f(cpustate->op1);

	appw = f2u(appf);
	cpustate->_OV = cpustate->_CY = 0;
	cpustate->_S = ((appw & 0x80000000) != 0);
	cpustate->_Z = (appw == 0);

	F2STOREOPFLOAT(cpustate, 2);
	F2END(cpustate)
}
Beispiel #24
0
int opDIVFS(void)
{
	UINT32 appw;
	float appf;

	F2DecodeFirstOperand(ReadAM, 2);
	F2DecodeSecondOperand(ReadAMAddress, 2);

	F2LOADOPFLOAT(2);

	appf *= u2f(f2Op1);

	appw = f2u(appf);
	_OV = _CY = 0;
	_S = ((appw & 0x80000000)!=0);
	_Z = (appw == 0);

	F2STOREOPFLOAT(2);
	F2END()
}
Beispiel #25
0
static UINT32 opSCLFS(v60_state *cpustate)
{
	UINT32 appw;
	float appf;

	F2DecodeFirstOperand(cpustate, ReadAM, 1);
	F2DecodeSecondOperand(cpustate, ReadAMAddress, 2);

	F2LOADOPFLOAT(cpustate, 2);

	if ((INT16)cpustate->op1 < 0)
		appf /= 1 << -(INT16)cpustate->op1;
	else
		appf *= 1 << cpustate->op1;

	appw = f2u(appf);
	cpustate->_OV = cpustate->_CY = 0;
	cpustate->_S = ((appw & 0x80000000) != 0);
	cpustate->_Z = (appw == 0);

	F2STOREOPFLOAT(cpustate, 2);
	F2END(cpustate)
}
Beispiel #26
0
int opSCLFS(void)
{
	UINT32 appw;
	float appf;

	F2DecodeFirstOperand(ReadAM, 1);
	F2DecodeSecondOperand(ReadAMAddress, 2);

	F2LOADOPFLOAT(2);

	if ((INT16)f2Op1 < 0)
		appf /= 1 << -(INT16)f2Op1;
	else
		appf *= 1 << f2Op1;

	appw = f2u(appf);
	_OV = _CY = 0;
	_S = ((appw & 0x80000000)!=0);
	_Z = (appw == 0);

	F2STOREOPFLOAT(2);
	F2END()
}
Beispiel #27
0
int main(int argc, char **argv)
{
    printf("---- VFMA (fp, VFPv4) ----\n");
    TESTINSN_bin_f64("vfma.f64 d0,  d11, d12", d0,  d11, i32, f2u0(-INFINITY), f2u1(-INFINITY), d12, i32, f2u0(NAN), f2u1(NAN));
    TESTINSN_bin_f64("vfma.f64 d7,  d1,  d6",  d7,  d1,  i32, f2u0(INFINITY), f2u1(INFINITY), d6, i32, f2u0(NAN), f2u1(NAN));
    TESTINSN_bin_f64("vfma.f64 d0,  d5,  d2",  d0,  d5,  i32, f2u0(NAN), f2u1(NAN), d2, i32, f2u0(-1.0), f2u1(-1.0));
    TESTINSN_bin_f64("vfma.f64 d10, d13, d15", d10, d13, i32, f2u0(NAN), f2u1(NAN), d15, i32, f2u0(0.0), f2u1(0.0));
    TESTINSN_bin_f64("vfma.f64 d10, d13, d15", d10, d13, i32, f2u0(NAN), f2u1(NAN), d15, i32, f2u0(NAN), f2u1(NAN));
    TESTINSN_bin_f64("vfma.f64 d20, d25, d22", d20, d25, i32, f2u0(23.04), f2u1(23.04), d22, i32, f2u0(-45.5687), f2u1(-45.5687));
    TESTINSN_bin_f64("vfma.f64 d23, d24, d25", d23, d24, i32, f2u0(-347856.475), f2u1(-347856.475), d25, i32, f2u0(1346), f2u1(1346));
    TESTINSN_bin_f64("vfma.f64 d20, d31, d12", d20, d31, i32, f2u0(48755), f2u1(48755), d12, i32, f2u0(-45786.476), f2u1(-45786.476));
    TESTINSN_bin_f64("vfma.f64 d19, d25, d27", d19, d25, i32, f2u0(95867.76), f2u1(95867.76), d27, i32, f2u0(17065), f2u1(17065));
    TESTINSN_bin_f64("vfma.f64 d30, d15, d2",  d30, d15, i32, f2u0(-45667.24), f2u1(-45667.24), d2, i32, f2u0(-248562.76), f2u1(-248562.76));
    TESTINSN_bin_f64("vfma.f64 d23, d24, d5",  d23, d24, i32, f2u0(24), f2u1(24), d5, i32, f2u0(1346), f2u1(1346));
    TESTINSN_bin_f64("vfma.f64 d10, d11, d2",  d10, d11, i32, f2u0(48755), f2u1(48755), d2, i32, f2u0(1089), f2u1(1089));
    TESTINSN_bin_f64("vfma.f64 d29, d15, d7",  d29, d15, i32, f2u0(214), f2u1(214), d7, i32, f2u0(1752065), f2u1(1752065));
    TESTINSN_bin_f64("vfma.f64 d30, d11, d12", d30, d11, i32, f2u0(356047.56), f2u1(356047.56), d12, i32, f2u0(5867.009), f2u1(5867.009));
    TESTINSN_bin_f64("vfma.f64 d27, d21, d6",  d27, d21, i32, f2u0(34.00046), f2u1(34.00046), d6, i32, f2u0(0.0024575), f2u1(0.0024575));
    TESTINSN_bin_f64("vfma.f64 d30, d31, d2",  d30, d31, i32, f2u0(2754), f2u1(2754), d2, i32, f2u0(107), f2u1(107));
    TESTINSN_bin_f64("vfma.f64 d13, d24, d5",  d13, d24, i32, f2u0(874), f2u1(874), d5, i32, f2u0(1384.6), f2u1(1384.6));
    TESTINSN_bin_f64("vfma.f64 d10, d11, d2",  d10, d11, i32, f2u0(487.587), f2u1(487.587), d2, i32, f2u0(109), f2u1(109));
    TESTINSN_bin_f64("vfma.f64 d29, d25, d7",  d29, d25, i32, f2u0(-INFINITY), f2u1(-INFINITY), d7, i32, f2u0(1752), f2u1(1752));
    TESTINSN_bin_f64("vfma.f64 d0,  d11, d12", d0,  d11, i32, f2u0(INFINITY), f2u1(INFINITY), d12, i32, f2u0(-5786.47), f2u1(-5786.47));
    TESTINSN_bin_f64("vfma.f64 d27, d21, d16", d27, d21, i32, f2u0(456.2489562), f2u1(456.2489562), d16, i32, f2u0(-7.2945676), f2u1(-7.2945676));
    TESTINSN_bin_f64("vfma.f64 d0,  d5,  d2",  d0,  d5,  i32, f2u0(INFINITY), f2u1(INFINITY), d2, i32, f2u0(-INFINITY), f2u1(-INFINITY));
    TESTINSN_bin_f64("vfma.f64 d20, d13, d15", d20, d13, i32, f2u0(-INFINITY), f2u1(-INFINITY), d15, i32, f2u0(0.0), f2u1(0.0));
    TESTINSN_bin_f64("vfma.f64 d10, d23, d15", d10, d23, i32, f2u0(INFINITY), f2u1(INFINITY), d15, i32, f2u0(0.0), f2u1(0.0));
    TESTINSN_bin_f32("vfma.f32 s0,  s11, s12", s0,  s11, i32, f2u(-INFINITY), s12, i32, f2u(NAN));
    TESTINSN_bin_f32("vfma.f32 s7,  s1,  s6",  s7,  s1,  i32, f2u(INFINITY), s6, i32, f2u(NAN));
    TESTINSN_bin_f32("vfma.f32 s0,  s5,  s2",  s0,  s5,  i32, f2u(NAN), s2, i32, f2u(-1.0));
    TESTINSN_bin_f32("vfma.f32 s10, s13, s15", s10, s13, i32, f2u(NAN), s15, i32, f2u(0.0));
    TESTINSN_bin_f32("vfma.f32 s10, s13, s15", s10, s13, i32, f2u(NAN), s15, i32, f2u(NAN));
    TESTINSN_bin_f32("vfma.f32 s20, s25, s22", s20, s25, i32, f2u(23.04), s22, i32, f2u(-45.5687));
    TESTINSN_bin_f32("vfma.f32 s23, s24, s25", s23, s24, i32, f2u(-347856.475), s25, i32, f2u(1346));
    TESTINSN_bin_f32("vfma.f32 s20, s31, s12", s20, s31, i32, f2u(48755), s12, i32, f2u(-45786.476));
    TESTINSN_bin_f32("vfma.f32 s19, s25, s27", s19, s25, i32, f2u(95867.76), s27, i32, f2u(17065));
    TESTINSN_bin_f32("vfma.f32 s30, s15, s2",  s30, s15, i32, f2u(-45667.24), s2, i32, f2u(-248562.76));
    TESTINSN_bin_f32("vfma.f32 s23, s24, s5",  s23, s24, i32, f2u(24), s5, i32, f2u(1346));
    TESTINSN_bin_f32("vfma.f32 s10, s11, s2",  s10, s11, i32, f2u(48755), s2, i32, f2u(1089));
    TESTINSN_bin_f32("vfma.f32 s29, s15, s7",  s29, s15, i32, f2u(214), s7, i32, f2u(1752065));
    TESTINSN_bin_f32("vfma.f32 s30, s11, s12", s30, s11, i32, f2u(356047.56), s12, i32, f2u(5867.009));
    TESTINSN_bin_f32("vfma.f32 s27, s21, s6",  s27, s21, i32, f2u(34.00046), s6, i32, f2u(0.0024575));
    TESTINSN_bin_f32("vfma.f32 s30, s31, s2",  s30, s31, i32, f2u(2754), s2, i32, f2u(107));
    TESTINSN_bin_f32("vfma.f32 s13, s24, s5",  s13, s24, i32, f2u(874), s5, i32, f2u(1384.6));
    TESTINSN_bin_f32("vfma.f32 s10, s11, s2",  s10, s11, i32, f2u(487.587), s2, i32, f2u(109));
    TESTINSN_bin_f32("vfma.f32 s29, s25, s7",  s29, s25, i32, f2u(-INFINITY), s7, i32, f2u(1752));
    TESTINSN_bin_f32("vfma.f32 s0,  s11, s12", s0,  s11, i32, f2u(INFINITY), s12, i32, f2u(-5786.47));
    TESTINSN_bin_f32("vfma.f32 s27, s21, s16", s27, s21, i32, f2u(456.2489562), s16, i32, f2u(-7.2945676));
    TESTINSN_bin_f32("vfma.f32 s0,  s5,  s2",  s0,  s5,  i32, f2u(INFINITY), s2, i32, f2u(-INFINITY));
    TESTINSN_bin_f32("vfma.f32 s20, s13, s15", s20, s13, i32, f2u(-INFINITY), s15, i32, f2u(0.0));
    TESTINSN_bin_f32("vfma.f32 s10, s23, s15", s10, s23, i32, f2u(INFINITY), s15, i32, f2u(0.0));

    printf("---- VFMS (fp, VFPv4) ----\n");
    TESTINSN_bin_f64("vfms.f64 d0,  d11, d12", d0,  d11, i32, f2u0(-INFINITY), f2u1(-INFINITY), d12, i32, f2u0(NAN), f2u1(NAN));
    TESTINSN_bin_f64("vfms.f64 d7,  d1,  d6",  d7,  d1,  i32, f2u0(INFINITY), f2u1(INFINITY), d6, i32, f2u0(NAN), f2u1(NAN));
    TESTINSN_bin_f64("vfms.f64 d0,  d5,  d2",  d0,  d5,  i32, f2u0(NAN), f2u1(NAN), d2, i32, f2u0(-1.0), f2u1(-1.0));
    TESTINSN_bin_f64("vfms.f64 d10, d13, d15", d10, d13, i32, f2u0(NAN), f2u1(NAN), d15, i32, f2u0(0.0), f2u1(0.0));
    TESTINSN_bin_f64("vfms.f64 d10, d13, d15", d10, d13, i32, f2u0(NAN), f2u1(NAN), d15, i32, f2u0(NAN), f2u1(NAN));
    TESTINSN_bin_f64("vfms.f64 d20, d25, d22", d20, d25, i32, f2u0(23.04), f2u1(23.04), d22, i32, f2u0(-45.5687), f2u1(-45.5687));
    TESTINSN_bin_f64("vfms.f64 d23, d24, d25", d23, d24, i32, f2u0(-347856.475), f2u1(-347856.475), d25, i32, f2u0(1346), f2u1(1346));
    TESTINSN_bin_f64("vfms.f64 d20, d31, d12", d20, d31, i32, f2u0(48755), f2u1(48755), d12, i32, f2u0(-45786.476), f2u1(-45786.476));
    TESTINSN_bin_f64("vfms.f64 d19, d25, d27", d19, d25, i32, f2u0(95867.76), f2u1(95867.76), d27, i32, f2u0(17065), f2u1(17065));
    TESTINSN_bin_f64("vfms.f64 d30, d15, d2",  d30, d15, i32, f2u0(-45667.24), f2u1(-45667.24), d2, i32, f2u0(-248562.76), f2u1(-248562.76));
    TESTINSN_bin_f64("vfms.f64 d23, d24, d5",  d23, d24, i32, f2u0(24), f2u1(24), d5, i32, f2u0(1346), f2u1(1346));
    TESTINSN_bin_f64("vfms.f64 d10, d11, d2",  d10, d11, i32, f2u0(48755), f2u1(48755), d2, i32, f2u0(1089), f2u1(1089));
    TESTINSN_bin_f64("vfms.f64 d29, d15, d7",  d29, d15, i32, f2u0(214), f2u1(214), d7, i32, f2u0(1752065), f2u1(1752065));
    TESTINSN_bin_f64("vfms.f64 d30, d11, d12", d30, d11, i32, f2u0(356047.56), f2u1(356047.56), d12, i32, f2u0(5867.009), f2u1(5867.009));
    TESTINSN_bin_f64("vfms.f64 d27, d21, d6",  d27, d21, i32, f2u0(34.00046), f2u1(34.00046), d6, i32, f2u0(0.0024575), f2u1(0.0024575));
    TESTINSN_bin_f64("vfms.f64 d30, d31, d2",  d30, d31, i32, f2u0(2754), f2u1(2754), d2, i32, f2u0(107), f2u1(107));
    TESTINSN_bin_f64("vfms.f64 d13, d24, d5",  d13, d24, i32, f2u0(874), f2u1(874), d5, i32, f2u0(1384.6), f2u1(1384.6));
    TESTINSN_bin_f64("vfms.f64 d10, d11, d2",  d10, d11, i32, f2u0(487.587), f2u1(487.587), d2, i32, f2u0(109), f2u1(109));
    TESTINSN_bin_f64("vfms.f64 d29, d25, d7",  d29, d25, i32, f2u0(-INFINITY), f2u1(-INFINITY), d7, i32, f2u0(1752), f2u1(1752));
    TESTINSN_bin_f64("vfms.f64 d0,  d11, d12", d0,  d11, i32, f2u0(INFINITY), f2u1(INFINITY), d12, i32, f2u0(-5786.47), f2u1(-5786.47));
    TESTINSN_bin_f64("vfms.f64 d27, d21, d16", d27, d21, i32, f2u0(456.2489562), f2u1(456.2489562), d16, i32, f2u0(-7.2945676), f2u1(-7.2945676));
    TESTINSN_bin_f64("vfms.f64 d0,  d5,  d2",  d0,  d5,  i32, f2u0(INFINITY), f2u1(INFINITY), d2, i32, f2u0(-INFINITY), f2u1(-INFINITY));
    TESTINSN_bin_f64("vfms.f64 d20, d13, d15", d20, d13, i32, f2u0(-INFINITY), f2u1(-INFINITY), d15, i32, f2u0(0.0), f2u1(0.0));
    TESTINSN_bin_f64("vfms.f64 d10, d23, d15", d10, d23, i32, f2u0(INFINITY), f2u1(INFINITY), d15, i32, f2u0(0.0), f2u1(0.0));
    TESTINSN_bin_f32("vfms.f32 s0,  s11, s12", s0,  s11, i32, f2u(-INFINITY), s12, i32, f2u(NAN));
    TESTINSN_bin_f32("vfms.f32 s7,  s1,  s6",  s7,  s1,  i32, f2u(INFINITY), s6, i32, f2u(NAN));
    TESTINSN_bin_f32("vfms.f32 s0,  s5,  s2",  s0,  s5,  i32, f2u(NAN), s2, i32, f2u(-1.0));
    TESTINSN_bin_f32("vfms.f32 s10, s13, s15", s10, s13, i32, f2u(NAN), s15, i32, f2u(0.0));
    TESTINSN_bin_f32("vfms.f32 s10, s13, s15", s10, s13, i32, f2u(NAN), s15, i32, f2u(NAN));
    TESTINSN_bin_f32("vfms.f32 s20, s25, s22", s20, s25, i32, f2u(23.04), s22, i32, f2u(-45.5687));
    TESTINSN_bin_f32("vfms.f32 s23, s24, s25", s23, s24, i32, f2u(-347856.475), s25, i32, f2u(1346));
    TESTINSN_bin_f32("vfms.f32 s20, s31, s12", s20, s31, i32, f2u(48755), s12, i32, f2u(-45786.476));
    TESTINSN_bin_f32("vfms.f32 s19, s25, s27", s19, s25, i32, f2u(95867.76), s27, i32, f2u(17065));
    TESTINSN_bin_f32("vfms.f32 s30, s15, s2",  s30, s15, i32, f2u(-45667.24), s2, i32, f2u(-248562.76));
    TESTINSN_bin_f32("vfms.f32 s23, s24, s5",  s23, s24, i32, f2u(24), s5, i32, f2u(1346));
    TESTINSN_bin_f32("vfms.f32 s10, s11, s2",  s10, s11, i32, f2u(48755), s2, i32, f2u(1089));
    TESTINSN_bin_f32("vfms.f32 s29, s15, s7",  s29, s15, i32, f2u(214), s7, i32, f2u(1752065));
    TESTINSN_bin_f32("vfms.f32 s30, s11, s12", s30, s11, i32, f2u(356047.56), s12, i32, f2u(5867.009));
    TESTINSN_bin_f32("vfms.f32 s27, s21, s6",  s27, s21, i32, f2u(34.00046), s6, i32, f2u(0.0024575));
    TESTINSN_bin_f32("vfms.f32 s30, s31, s2",  s30, s31, i32, f2u(2754), s2, i32, f2u(107));
    TESTINSN_bin_f32("vfms.f32 s13, s24, s5",  s13, s24, i32, f2u(874), s5, i32, f2u(1384.6));
    TESTINSN_bin_f32("vfms.f32 s10, s11, s2",  s10, s11, i32, f2u(487.587), s2, i32, f2u(109));
    TESTINSN_bin_f32("vfms.f32 s29, s25, s7",  s29, s25, i32, f2u(-INFINITY), s7, i32, f2u(1752));
    TESTINSN_bin_f32("vfms.f32 s0,  s11, s12", s0,  s11, i32, f2u(INFINITY), s12, i32, f2u(-5786.47));
    TESTINSN_bin_f32("vfms.f32 s27, s21, s16", s27, s21, i32, f2u(456.2489562), s16, i32, f2u(-7.2945676));
    TESTINSN_bin_f32("vfms.f32 s0,  s5,  s2",  s0,  s5,  i32, f2u(INFINITY), s2, i32, f2u(-INFINITY));
    TESTINSN_bin_f32("vfms.f32 s20, s13, s15", s20, s13, i32, f2u(-INFINITY), s15, i32, f2u(0.0));
    TESTINSN_bin_f32("vfms.f32 s10, s23, s15", s10, s23, i32, f2u(INFINITY), s15, i32, f2u(0.0));

    return 0;
}
Beispiel #28
0
unsigned test_float_i2f(int x) {
  float f = (float) x;
  return f2u(f);
}
Beispiel #29
0
static int get_panel(int oid, data_panel *panel, size_t size)
{
	int ret = (s32b) size;
	switch(oid)
	{
  case 1:
  {
	int i = 0;
	assert( size >= (u32b) boundaries[1].page_rows);
	ret = boundaries[1].page_rows;
	P_I(TERM_L_BLUE, "Name",	"%y",	s2u(op_ptr->full_name), END  );
	P_I(TERM_L_BLUE, "Sex",		"%y",	s2u(sp_ptr->title), END  );
	P_I(TERM_L_BLUE, "Race",	"%y",	s2u(rp_ptr->name), END  );
	P_I(TERM_L_BLUE, "Class",	"%y",	s2u(cp_ptr->name), END  );
	P_I(TERM_L_BLUE, "Title",	"%y",	s2u(show_title()), END  );
	P_I(TERM_L_BLUE, "HP",	"%y/%y",	i2u(p_ptr->chp), i2u(p_ptr->mhp)  );
	P_I(TERM_L_BLUE, "SP",	"%y/%y",	i2u(p_ptr->csp), i2u(p_ptr->msp)  );
	P_I(TERM_L_BLUE, "Level",	"%y",	i2u(p_ptr->lev), END  );
	assert(i == boundaries[1].page_rows);
	return ret;
  }
  case 2:
  {
	int i = 0;
	assert( ret >= boundaries[2].page_rows);
	ret = boundaries[2].page_rows;
	P_I(max_color(p_ptr->lev, p_ptr->max_lev), "Level", "%y", i2u(p_ptr->lev), END  );
	P_I(max_color(p_ptr->exp, p_ptr->max_exp), "Cur Exp", "%y", i2u(p_ptr->exp), END  );
	P_I(TERM_L_GREEN, "Max Exp",	"%y",	i2u(p_ptr->max_exp), END  );
	P_I(TERM_L_GREEN, "Adv Exp",	"%y",	s2u(show_adv_exp()), END  );
	P_I(TERM_L_GREEN, "MaxDepth",	"%y",	s2u(show_depth()), END  );
	P_I(TERM_L_GREEN, "Game Turns",	"%y",	i2u(turn), END  );
	P_I(TERM_L_GREEN, "Standard Turns","%y", i2u(p_ptr->total_energy / 100), END  );
	P_I(TERM_L_GREEN, "Resting Turns","%y",	i2u(p_ptr->resting_turn), END  );
	P_I(TERM_L_GREEN, "Gold",		"%y",	i2u(p_ptr->au), END  );
	assert(i == boundaries[2].page_rows);
	return ret;
  }
  case 3:
  {
	int i = 0;
	assert(ret >= boundaries[3].page_rows);
	ret = boundaries[3].page_rows;
	P_I(TERM_L_BLUE, "Armor", "[%y,%+y]",	i2u(p_ptr->state.dis_ac), i2u(p_ptr->state.dis_to_a)  );
	P_I(TERM_L_BLUE, "Fight", "(%+y,%+y)",	i2u(p_ptr->state.dis_to_h), i2u(p_ptr->state.dis_to_d)  );
	P_I(TERM_L_BLUE, "Melee", "%y",		s2u(show_melee_weapon(&p_ptr->inventory[INVEN_WIELD])), END  );
	P_I(TERM_L_BLUE, "Shoot", "%y",		s2u(show_missile_weapon(&p_ptr->inventory[INVEN_BOW])), END  );
	P_I(TERM_L_BLUE, "Blows", "%y.%y/turn",	i2u(p_ptr->state.num_blow / 100), i2u((p_ptr->state.num_blow / 10) % 10) );
	P_I(TERM_L_BLUE, "Shots", "%y/turn",	i2u(p_ptr->state.num_fire), END  );
	P_I(TERM_L_BLUE, "Infra", "%y ft",	i2u(p_ptr->state.see_infra * 10), END  );
	P_I(TERM_L_BLUE, "Speed", "%y",		s2u(show_speed()), END );
	P_I(TERM_L_BLUE, "Burden","%.1y lbs",	f2u(p_ptr->total_weight/10.0), END  );
	assert(i == boundaries[3].page_rows);
	return ret;
  }
  case 4:
  {
	static struct {
		const char *name;
		int skill;
		int div;
	} skills[] =
	{
		{ "Saving Throw", SKILL_SAVE, 6 },
		{ "Stealth", SKILL_STEALTH, 1 },
		{ "Fighting", SKILL_TO_HIT_MELEE, 12 },
		{ "Shooting", SKILL_TO_HIT_BOW, 12 },
		{ "Disarming", SKILL_DISARM, 8 },
		{ "Magic Device", SKILL_DEVICE, 6 },
		{ "Perception", SKILL_SEARCH_FREQUENCY, 6 },
		{ "Searching", SKILL_SEARCH, 6 }
	};
	int i;
	assert(N_ELEMENTS(skills) == boundaries[4].page_rows);
	ret = N_ELEMENTS(skills);
	if ((u32b) ret > size) ret = size;
	for (i = 0; i < ret; i++)
	{
		s16b skill = p_ptr->state.skills[skills[i].skill];
		panel[i].color = TERM_L_BLUE;
		panel[i].label = skills[i].name;
		if (skills[i].skill == SKILL_SAVE ||
				skills[i].skill == SKILL_SEARCH)
		{
			if (skill < 0) skill = 0;
			if (skill > 100) skill = 100;
			panel[i].fmt = "%y%%";
			panel[i].value[0] = i2u(skill);
			panel[i].color = colour_table[skill / 10];
		}
		else if (skills[i].skill == SKILL_DEVICE)
		{
			panel[i].fmt = "%y";
			panel[i].value[0] = i2u(skill);
			panel[i].color = colour_table[skill / 13];
		}
		else if (skills[i].skill == SKILL_SEARCH_FREQUENCY)
		{
			if (skill <= 0) skill = 1;
			if (skill >= 50)
			{
				panel[i].fmt = "1 in 1";
				panel[i].color = colour_table[10];
			}
			else
			{
				/* convert to % chance of searching */
				skill = 50 - skill;
				panel[i].fmt = "1 in %y";
				panel[i].value[0] = i2u(skill);
				panel[i].color =
					colour_table[(100 - skill*2) / 10];
			}
		}
		else if (skills[i].skill == SKILL_DISARM)
		{
			/* assume disarming a dungeon trap */
			skill -= 5;
			if (skill > 100) skill = 100;
			if (skill < 2) skill = 2;
			panel[i].fmt = "%y%%";
			panel[i].value[0] = i2u(skill);
			panel[i].color = colour_table[skill / 10];
		}
		else
		{
			panel[i].fmt = "%y";
			panel[i].value[0] = s2u(likert(skill, skills[i].div, &panel[i].color));
		}
	}
	return ret;
  }
  case 5:
  {
	int i = 0;
	assert(ret >= boundaries[5].page_rows);
	ret = boundaries[5].page_rows;
	P_I(TERM_L_BLUE, "Age",			"%y",	i2u(p_ptr->age), END );
	P_I(TERM_L_BLUE, "Height",		"%y",	i2u(p_ptr->ht), END  );
	P_I(TERM_L_BLUE, "Weight",		"%y",	i2u(p_ptr->wt), END  );
	P_I(TERM_L_BLUE, "Social",		"%y",	s2u(show_status()), END  );
	P_I(TERM_L_BLUE, "Maximize",	"%y",	c2u(OPT(birth_maximize) ? 'Y' : 'N'), END);
#if 0
	/* Preserve mode deleted */
	P_I(TERM_L_BLUE, "Preserve",	"%y",	c2u(birth_preserve ? 'Y' : 'N'), END);
#endif
	assert(i == boundaries[5].page_rows);
	return ret;
  }
 }
	/* hopefully not reached */
	return 0;
}
Beispiel #30
0
void show_float_ge(float x, float y)
{
	printf("0x%08X, 0x%08X\n", f2u(x), f2u(y));
	printf("float_ge(%f, %f) = %d\n", x, y, float_ge(x, y));
	printf("\n");
}