Example #1
0
static void test_const(void)
{
  print_float("const0", FLT_MAX);
  print_float("const1", FLT_MIN);
  print_float("const2", (float)INT_MAX);
  print_float("const3", (float)INT_MIN);
  print_float("const4", PI);
}
Example #2
0
static void test_pow(void)
{
  print_float("pow0", IEEESPPow(0.0f, 0.0f));
  print_float("pow1", IEEESPPow(1000.0f, 0.0f));
  print_float("pow2", IEEESPPow(FLT_MAX, FLT_MAX));
  print_float("pow3", IEEESPPow(-1000.0f, -1000.0f));
  print_float("pow4", IEEESPPow(3.0f, 4.0f));
}
int
main (int argc, char **argv)
{
  char limit[1 + MAX (INT_BUFSIZE_BOUND (intmax_t),
                      INT_BUFSIZE_BOUND (uintmax_t))];

  initialize_main (&argc, &argv);
  set_program_name (argv[0]);
  setlocale (LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  initialize_exit_failure (EXIT_FAILURE);
  atexit (close_stdout);

  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
                      usage, AUTHORS, (char const *) NULL);

#define print_int(TYPE)                                                  \
  sprintf (limit + 1, "%"PRIuMAX, (uintmax_t) TYPE##_MAX);               \
  printf (#TYPE"_MAX=%s\n", limit + 1);                                  \
  printf (#TYPE"_OFLOW=%s\n", decimal_absval_add_one (limit));           \
  if (TYPE##_MIN)                                                        \
    {                                                                    \
      sprintf (limit + 1, "%"PRIdMAX, (intmax_t) TYPE##_MIN);            \
      printf (#TYPE"_MIN=%s\n", limit + 1);                              \
      printf (#TYPE"_UFLOW=%s\n", decimal_absval_add_one (limit));       \
    }

#define print_float(TYPE)                                                \
  printf (#TYPE"_MIN=%Le\n", (long double)TYPE##_MIN);                   \
  printf (#TYPE"_MAX=%Le\n", (long double)TYPE##_MAX);

  /* Variable sized ints */
  print_int (CHAR);
  print_int (SCHAR);
  print_int (UCHAR);
  print_int (SHRT);
  print_int (INT);
  print_int (UINT);
  print_int (LONG);
  print_int (ULONG);
  print_int (SIZE);
  print_int (SSIZE);
  print_int (TIME_T);
  print_int (UID_T);
  print_int (GID_T);
  print_int (PID_T);
  print_int (OFF_T);
  print_int (INTMAX);
  print_int (UINTMAX);

  /* Variable sized floats */
  print_float (FLT);
  print_float (DBL);
  print_float (LDBL);
}
Example #4
0
void	print_discriminant(float *tab, float delta)
{
	ft_putstr(ft_strjoin("a=", print_float(tab[2])));
	ft_putstr(ft_strjoin(", b=", print_float(tab[1])));
	ft_putendl(ft_strjoin(", c=", print_float(tab[0])));
	ft_putstr("Discriminant = b");
	ft_wputchar(0xB2);
	ft_putendl(" - 4ac");
	ft_putendl(ft_strjoin("Discriminant = ", print_float(delta)));
}
Example #5
0
void print_accels(void)//print acceleration data using print_float
{
	for (arraypos = 1; arraypos < 32; arraypos++)
	{
		print_float(times[arraypos]);
		printf(",");
		print_float(accels[arraypos]);
		printf("\n");
	}
}
Example #6
0
//draws UI elements to the screen and accepts user input
//  loc_state_t* loc - the location data to use/modify
void ui_update(loc_state_t* loc){
  char curr_button = NO_BUTTON;

  timer++;

  curr_button = keypad_getchar();
  if( curr_button == LEFT_BUTTON ){
    bottom_screen--;
  } else if( curr_button == RIGHT_BUTTON ){
    bottom_screen++;
  }
  //if(bottom_screen > MAX_PAGE){
    //bottom_screen = MIN_PAGE;
  //}
  bottom_screen = bottom_screen % (MAX_PAGE+1);

  lcd_clrscr();
  //draw the destination info on row 0
  ui_draw_dest_info(DEST_ROW, loc);

  if( bottom_screen == SAT_PAGE ){
    ui_draw_sat_info(PAGE_ROW, loc);
  } else if( bottom_screen == DRIVING_PAGE ){
    ui_draw_driving_info(PAGE_ROW, loc);
  } else if( bottom_screen == MEM_PAGE ){
    lcd_gotoxy(0, PAGE_ROW);
    lcd_puts_P("4)LOAD    6)SAVE");
    if( curr_button == '4' ){
      ui_load_screen(loc);
    } else if( curr_button == '6' ){
      ui_save_screen(loc);
    }
  } else if( bottom_screen == DESTLOC_PAGE ){
    lcd_gotoxy(0, PAGE_ROW);
    if( (timer & _BV(2)) == 0 ){
      lcd_puts_P("DLa ");
      print_float(loc->dest_lat);
    } else {
      lcd_puts_P("DLo ");
      print_float(loc->dest_long);
    }
  } else if( bottom_screen == CURRLOC_PAGE ){
    lcd_gotoxy(0, PAGE_ROW);
    if( (timer & _BV(2)) == 0 ){
      lcd_puts_P("CLa ");
      print_float(loc->curr_lat);
    } else {
      lcd_puts_P("CLo ");
      print_float(loc->curr_long);
    }
  }
}
Example #7
0
void MeanValues(void)
{
	float aux;

		i++;
		Vom += Vout;
		Vim += Vin;
		if (mode == 1)
		{
			if((LPC_GPIO2->FIOPIN & 0x0008) || (CurrentState == BOOST_SOFT))
			Iom += Il;
		    if(LPC_GPIO2->FIOPIN & 0x0002)
			Iim += Il;
		}
		else
		{
			if((LPC_GPIO2->FIOPIN & 0x0002) || (CurrentState == BOOST_SOFT))
			Iom += Il;
		    if(LPC_GPIO2->FIOPIN & 0x0008)
			Iim += Il;
		}

		if((i % 100000) == 0)
		{
			Vo = Vom / 100000;
			Vi = Vim / 100000;
			Io = Iom / 100000;
			Ii = Iim / 100000;
			Vom = 0;
			Vim = 0;
			Iom = 0;
			Iim = 0;
}
#ifdef ShowPeriodically
	if(i >= 100000)
	{
		i = 1;
		print("\r\n Vo:");
		aux = (Vo * Vdd * 28) / (4095 * 3);
		print_float(&aux);
		print(" Vin:");
		aux = (Vi * Vdd * 28) / (4095 * 3);
		print_float(&aux);
		print(" Io:");
		aux = (Io * Vdd * 2) / (4095 * 0.151);
		print_float(&aux);
		print(" Ii:");
		aux = (Ii * Vdd * 2) / (4095 * 0.151);
		print_float(&aux);
	}
#endif
}
Example #8
0
void cmd_ShowParams(char *cmd)
{
	float aux;
	print("\t\t Vref:");
	aux = (Vref * Vdd * 28) / (4095 * 3);
	print_float(&aux);
	print(" Imax:");
	aux = (Imax * Vdd * 2) / (4095 * 0.151);
	print_float(&aux);
	print(" Vmax:");
	aux = (Vmax * Vdd * 28) / (4095 * 3);
	print_float(&aux);
}
Example #9
0
void begin(void)
{
  int val = 0;
  const int limit = 10000;
  int i, j, base;
  float W[DEPTH];
  float buff[DEPTH];
  int bufflast;
  
  // Calculate weights:
  for (i = 0; i < DEPTH; i++)
    W[i] = (float)(2*i*i) / (float)(i+1);
  // Prefill buffer:
  for (i = 0; i < DEPTH; i++)
    buff[i] = 0;
  bufflast = 0;
  base = 0;
  
  /* Main loop: */
  while (numiters == -1 || numiters-- > 0)
  {
    // Calculate a sliding window over the (circular) buffer.
    float s = 0;
    for (i = 0; i < DEPTH; i++)
        s += W[i] * buff[(base + i) % DEPTH];

    // Calculate the next elements.
    base--;
    if (base < 0) base += DEPTH;
    buff[base] = bufflast++;
      
    print_float(s);
  }
}
Example #10
0
void		print_arg_float(t_e *e, t_a *a, int *i)
{
	double		va;

	va = va_arg(e->ap, double);
	*i = print_float(va, a);
}
Example #11
0
void cmd_ShowValues(char *cmd)
{
	float aux;
	print("\t\t Vo:");
	aux = (Vo * Vdd * 28) / (4095 * 3);
	print_float(&aux);
	print(" Vin:");
	aux = (Vi * Vdd * 28) / (4095 * 3);
	print_float(&aux);
	print(" Io:");
	aux = (Io * Vdd * 2) / (4095 * 0.151);
	print_float(&aux);
	print(" Ii:");
	aux = (Ii * Vdd * 2) / (4095 * 0.151);
	print_float(&aux);
}
Example #12
0
void check_type(char type)  
{  
  switch(type)
  {  
    case 'd':
    {  
      int num = va_arg(args, int);  
  
      if(num < 0){  
        UsartPut('-');  
        num = num * (-1);  
      }  
  
      print_int(num, 10, 0);  
      break;  
    }  
  
    case 'c':
    {  
      char ch = (char)va_arg(args, int);  
      UsartPut(ch);  
      break;  
    }  
    
    case 's':
    {  
      char *str = va_arg(args, char *);  
      print_str(str);  
      break;  
    }  
    
    case 'f':
    {  
      float num = (float)va_arg(args, double);  
    
      if(num < 0)  {  
        UsartPut('-');  
        num = num * (-1);  
      }  
    
      print_float(num);  
      break;  
    }  
    
    case 'p':
    {  
      int num = va_arg(args, int);  
      UsartPut('0');  
      UsartPut('x');  
      print_int(num, 16, 0);  
      break;  
    }  
    
    default:
    {  
      UsartPut('%');  
      UsartPut(type);  
    }  
  }  
}  
Example #13
0
void print_object (STREAM stream, D instance, BOOL escape_p, int print_depth) {
  enum dylan_type_enum type = dylan_type(instance);
  switch (type) {
    case integer_type:
      print_integer(stream, instance, escape_p, print_depth); break;
    case character_type:
      print_character(stream, instance, escape_p, print_depth); break;
    case float_type:
      print_float (stream, instance, escape_p, print_depth); break;
    case dylan_boolean_type:
      print_boolean(stream, instance, escape_p, print_depth); break;
    case string_type:
      print_string (stream, instance, escape_p, print_depth); break;
    case vector_type:
      print_vector(stream, instance, escape_p, print_depth); break;
    case pair_type:
      print_pair(stream, instance, escape_p, print_depth); break;
    case empty_list_type:
      print_empty_list(stream, instance, escape_p, print_depth); break;
    case symbol_type:
      print_symbol(stream, instance, escape_p, print_depth); break;
    case simple_condition_type:
      print_simple_condition(stream, instance, escape_p, print_depth); break;
    case class_type:
      print_class(stream, instance, escape_p, print_depth); break;
    case function_type:
      print_function(stream, instance, escape_p, print_depth); break;
    case unknown_type:
      format(stream, "?%lx", instance); break;
    default:
      print_user_defined(stream, instance, escape_p, print_depth); break;
  }
}
Example #14
0
void begin(void){

  float r[N_sim];
  float y[N_sim];
  float H[N_ch][N_col];
  float F[N_ch][N_col];

		
  int i,j;

  for (i=0;i<N_sim;i++)
      r[i]=i+1;


  for (i=0;i<N_col;i++) {

      for (j=0;j<N_ch;j++){
	  H[j][i]=i*N_col+j*N_ch+j+i+j+1;

	  F[j][i]=i*j+j*j+j+i;
	
      }
  }

  while (numiters == -1 || numiters-- > 0) {
    FBCore(N_samp,N_ch,N_col,r,y,H,F);
    for (i=0;i<N_sim;i++) {
#ifdef raw
      print_float(y[i]);
#else
      printf("%f\n", y[i]);
#endif
    }
  }
}
Example #15
0
void main(){
    int n = read_int();
    float x = 0.1;
    for(int i=0;i<n;i=i+1){
        print_float(x);
        x = x+0.1;
    }
}
void showStruct(struct Student a)
{
	print(a.id);
	print_char('\t');
	print_float(a.score);
	print_char('\t');
	print_char(a.name);
	print_char('\n');
}
Example #17
0
// invoca varias funciones
void test(){
    float aux;
    aux = 2.0; 
    print_int(gcd(factorial(3),factorial(4)));
    print_int(nthprimeArray(gcd(factorial(3),factorial(4))));
    
    aux = potenciaR(aux,nthprimeArray(gcd(factorial(3),factorial(4))));
    print_float(aux);
}
Example #18
0
std::basic_string<Char> float_to_string(double val, int precision)
{
	std::basic_ostringstream<Char> ss;
    ss.imbue(std::locale::classic());
    {
        buffered_ostream<Char> os(ss);
        print_float(val, precision, os);
    }
	return ss.str();
}
Example #19
0
void write_floats(FloatBuffer *fb)
{
  /* printf() any data that's available: */
#ifdef raw
  while (fb->rpos < fb->rlen)
    print_float(fb->buff[fb->rpos++]);
#else
  while (fb->rpos < fb->rlen)
    printf("%f\n", fb->buff[fb->rpos++]);
#endif
}
Example #20
0
void floatBits1(float number) {
    union {
        float f;
        int i;
    } x;
    x.f = number;
    int sign = (x.i >> 31) & 1;
    int exp = (x.i >> 23) & 0xff;
    int man = x.i & 0x7fffff;
    print_float(sign, exp, man);
}
Example #21
0
static void test_cos(void)
{
  print_float("cos0", IEEESPCos(0.0f));
  print_float("cos1", IEEESPCos(PI));
  print_float("cos2", IEEESPCos(-PI));
  print_float("cos3", IEEESPCos(FLT_MIN));
  print_float("cos4", IEEESPCos(FLT_MAX));
  print_float("cos5", IEEESPCos(FLT_MIN_NEG));
  print_float("cos6", IEEESPCos(FLT_MAX_NEG));
}
Example #22
0
static void test_log(void)
{
  print_float("log0", IEEESPLog(0.0f));
  print_float("log1", IEEESPLog(PI));
  print_float("log2", IEEESPLog(-PI));
  print_float("log3", IEEESPLog(FLT_MIN));
  print_float("log4", IEEESPLog(FLT_MAX));
  print_float("log5", IEEESPLog(FLT_MIN_NEG));
  print_float("log6", IEEESPLog(FLT_MAX_NEG));
}
Example #23
0
static void test_log10(void)
{
  print_float("logt0", IEEESPLog10(0.0f));
  print_float("logt1", IEEESPLog10(10.0f));
  print_float("logt2", IEEESPLog10(-10.0f));
  print_float("logt3", IEEESPLog10(FLT_MIN));
  print_float("logt4", IEEESPLog10(FLT_MAX));
  print_float("logt5", IEEESPLog10(FLT_MIN_NEG));
  print_float("logt6", IEEESPLog10(FLT_MAX_NEG));
}
Example #24
0
static void test_sin(void)
{
  print_float("sin0", IEEESPSin(0.0f));
  print_float("sin1", IEEESPSin(PI));
  print_float("sin2", IEEESPSin(-PI));
  print_float("sin3", IEEESPSin(FLT_MIN));
  print_float("sin4", IEEESPSin(FLT_MAX));
  print_float("sin5", IEEESPSin(FLT_MIN_NEG));
  print_float("sin6", IEEESPSin(FLT_MAX_NEG));
}
Example #25
0
static void test_sqrt(void)
{
  print_float("sqrt0", IEEESPSqrt(0.0f));
  print_float("sqrt1", IEEESPSqrt(2.0f));
  print_float("sqrt2", IEEESPSqrt(-2.0f));
  print_float("sqrt3", IEEESPSqrt(FLT_MIN));
  print_float("sqrt4", IEEESPSqrt(FLT_MAX));
  print_float("sqrt5", IEEESPSqrt(FLT_MIN_NEG));
  print_float("sqrt6", IEEESPSqrt(FLT_MAX_NEG));
}
Example #26
0
static void test_tanh(void)
{
  print_float("tanh0", IEEESPTanh(0.0f));
  print_float("tanh1", IEEESPTanh(PI));
  print_float("tanh2", IEEESPTanh(-PI));
  print_float("tanh3", IEEESPTanh(FLT_MIN));
  print_float("tanh4", IEEESPTanh(FLT_MAX));
  print_float("tanh5", IEEESPTanh(FLT_MIN_NEG));
  print_float("tanh6", IEEESPTanh(FLT_MAX_NEG));
}
Example #27
0
static void test_tieee(void)
{
  print_float("tieee0", IEEESPTieee(0.0f));
  print_float("tieee1", IEEESPTieee(PI));
  print_float("tieee2", IEEESPTieee(-PI));
  print_float("tieee2", IEEESPTieee(FLT_MIN));
  print_float("tieee3", IEEESPTieee(FLT_MAX));
  print_float("tieee4", IEEESPTieee(FLT_MIN_NEG));
  print_float("tieee5", IEEESPTieee(FLT_MAX_NEG));
}
Example #28
0
static void test_atan(void)
{
  print_float("atan0", IEEESPAtan(0.0f));
  print_float("atan1", IEEESPAtan(PI));
  print_float("atan2", IEEESPAtan(-PI));
  print_float("atan3", IEEESPAtan(FLT_MIN));
  print_float("atan4", IEEESPAtan(FLT_MAX));
  print_float("atan5", IEEESPAtan(FLT_MIN_NEG));
  print_float("atan6", IEEESPAtan(FLT_MAX_NEG));
}
Example #29
0
static void test_cosh(void)
{
  print_float("cosh0", IEEESPCosh(0.0f));
  print_float("cosh1", IEEESPCosh(PI));
  print_float("cosh2", IEEESPCosh(-PI));
  print_float("cosh3", IEEESPCosh(FLT_MIN));
  print_float("cosh4", IEEESPCosh(FLT_MAX));
  print_float("cosh5", IEEESPCosh(FLT_MIN_NEG));
  print_float("cosh6", IEEESPCosh(FLT_MAX_NEG));
}
Example #30
0
static void test_exp(void)
{
  print_float("exp0", IEEESPExp(0.0f));
  print_float("exp1", IEEESPExp(PI));
  print_float("exp2", IEEESPExp(-PI));
  print_float("exp3", IEEESPExp(FLT_MIN));
  print_float("exp4", IEEESPExp(FLT_MAX));
  print_float("exp5", IEEESPExp(FLT_MIN_NEG));
  print_float("exp6", IEEESPExp(FLT_MAX_NEG));
}