Ejemplo n.º 1
0
void test_fp_utilities( void )
{
#if __STDC_VERSION__ >= 199901L
    printf( "Testing C99 miscellaneous functions...\n" );

    VERIFY( CompDbl( copysign( -2.0, 1.0), 2.0 ) );
    VERIFY( CompDbl( copysign( -2.0, -1.0), -2.0 ) );
    VERIFY( CompDbl( copysign( 2.0, -1.0), -2.0 ) );
    VERIFY( CompDbl( copysign( 2.0, 1.0), 2.0 ) );
    
    VERIFY( CompDbl( fmax( 2.0, 1.0), 2.0 ) );
    VERIFY( CompDbl( fmax( -2.0, -1.0), -1.0 ) );
    VERIFY( CompDbl( fmin( 2.0, 1.0), 1.0 ) );
    VERIFY( CompDbl( fmin( -2.0, -1.0), -2.0 ) );
    
    VERIFY( CompDbl( fma( 2.0, 3.0, 4.0), 10.0 ) );
    VERIFY( CompDbl( fma( 2.0, 3.0, -4.0), 2.0 ) );
    VERIFY( CompDbl( fma( -2.0, 3.0, 4.0), -2.0 ) );
    VERIFY( CompDbl( fma( -2.0, -3.0, 4.0), 10.0 ) );
    
    VERIFY( CompDbl( fdim( 3.0, 2.0), 1.0 ) );
    VERIFY( CompDbl( fdim( 2.0, 3.0), 0.0 ) );
    
    VERIFY( CompDbl( nextafter( 1.0, 2.0), 1.0+1.0E-16 ) );
    VERIFY( CompDbl( nextafter( 1.0, 0.0), 1.0-1.0E-16 ) );
    
    VERIFY( CompDbl( scalbn( 1.0, 3.0), 8.0 ) );
    VERIFY( CompDbl( scalbn( 4.0, 3.0), 32.0 ) );
#endif
}
Ejemplo n.º 2
0
void test_fdim()
{
    static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
    static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
    static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
    assert(fdim(1,0) == 1);
}
Ejemplo n.º 3
0
bool
InfoBoxContentSpeedGround::HandleKey(const InfoBoxKeyCodes keycode)
{
    if (!is_simulator())
        return false;
    if (!CommonInterface::Basic().gps.simulator)
        return false;

    const auto fixed_step = (fixed)Units::ToSysSpeed(fixed(10));
    const auto a5 = Angle::Degrees(5);

    switch (keycode) {
    case ibkUp:
        device_blackboard->SetSpeed(
            CommonInterface::Basic().ground_speed + fixed_step);
        return true;

    case ibkDown:
        device_blackboard->SetSpeed(fdim(CommonInterface::Basic().ground_speed,
                                         fixed_step));
        return true;

    case ibkLeft:
        device_blackboard->SetTrack(CommonInterface::Basic().track - a5);
        return true;

    case ibkRight:
        device_blackboard->SetTrack(CommonInterface::Basic().track + a5);
        return true;
    }

    return false;
}
Ejemplo n.º 4
0
void
Math_fdim(void *fp)
{
	F_Math_fdim *f;

	f = fp;

	*f->ret = fdim(f->x, f->y);
}
Ejemplo n.º 5
0
void
ElementStat::SetTimes(const double until_start_s, const double ts,
                      const double time)
{
  time_started = ts;

  if (time_started < 0 || time < 0)
    /* not yet started */
    time_elapsed = 0;
  else
    time_elapsed = fdim(time, ts);

  if (solution_remaining.IsOk()) {
    time_remaining_now = solution_remaining.time_elapsed;
    time_remaining_start = fdim(time_remaining_now, until_start_s);
    time_planned = time_elapsed + time_remaining_start;
  } else {
    time_remaining_now = time_remaining_start = time_planned = 0;
  }
}
Ejemplo n.º 6
0
void
ElementStat::SetTimes(const fixed until_start_s, const fixed ts,
                      const fixed time)
{
  time_started = ts;

  if (negative(time_started) || negative(time))
    /* not yet started */
    time_elapsed = fixed(0);
  else
    time_elapsed = fdim(time, ts);

  if (solution_remaining.IsOk()) {
    time_remaining_now = solution_remaining.time_elapsed;
    time_remaining_start = fdim(time_remaining_now, until_start_s);
    time_planned = time_elapsed + time_remaining_start;
  } else {
    time_remaining_now = time_remaining_start = time_planned = fixed(0);
  }
}
Ejemplo n.º 7
0
inline double
TaskLeg::GetScoredDistance(const GeoPoint &ref) const
{
  if (!GetOrigin())
    return 0;

  switch (destination.GetActiveState()) {
  case OrderedTaskPoint::BEFORE_ACTIVE:
    // this leg totally included
    return fdim(GetOrigin()->GetLocationScored().Distance(destination.GetLocationScored()),
                GetOrigin()->ScoreAdjustment()-destination.ScoreAdjustment());

  case OrderedTaskPoint::CURRENT_ACTIVE:
    // this leg partially included
    if (destination.HasEntered()) {
      return fdim(GetOrigin()->GetLocationScored().Distance(destination.GetLocationScored()),
                  GetOrigin()->ScoreAdjustment()-destination.ScoreAdjustment());
    } else if (ref.IsValid())
      return fdim(ref.ProjectedDistance(GetOrigin()->GetLocationScored(),
                                        destination.GetLocationScored()),
                  GetOrigin()->ScoreAdjustment());
    else
      return 0;

  case OrderedTaskPoint::AFTER_ACTIVE:
    // this leg may be partially included
    if (GetOrigin()->HasEntered() && ref.IsValid()) {
      return fdim(memo_travelled.calc(GetOrigin()->GetLocationScored(),
                                      ref).distance,
                  GetOrigin()->ScoreAdjustment());
    }

    return 0;
  }

  gcc_unreachable();
  assert(false);
  return 0;
}
Ejemplo n.º 8
0
TractCluster::TractCluster(const float* param):error_distance(param[3])
{
    image::vector<3,float> fdim(param);
    fdim /= error_distance;
    fdim += 1.0;
    fdim.floor();
    dim[0] = fdim[0];
    dim[1] = fdim[1];
    dim[2] = fdim[2];
    w = dim[0];
    wh = dim[0]*dim[1];
    voxel_connection.resize(dim.size());

}
double metric_cmp(struct path_stats *ps1, struct path_stats *ps2)
{
    double diff = 0;

    if(ps1->delay != ps2->delay){
        diff += fdim(ps1->delay, ps2->delay) / fmax(ps1->delay, ps2->delay);
    }

    if(ps1->loss != ps2->loss){
        diff += fdim(ps1->loss, ps2->loss) / fmax(ps1->loss, ps2->loss);
    }

    if(ps1->jitter != ps2->jitter){
        diff += fdim(ps1->jitter, ps2->jitter) / fmax(ps1->jitter, ps2->jitter);
    }

    if(ps1->bandwidth != ps2->bandwidth){
        diff += fdim(ps1->bandwidth, ps2->bandwidth)
                / fmax(ps1->bandwidth, ps2->bandwidth);
    }

    return diff;
}
Ejemplo n.º 10
0
void Adaptive::updateProbsBasic(const double wgt)
{
    const double pStar = probability[currentIndex];
    const double alpha = fdim(1.0,pStar), beta = pStar;
    vector<double>::iterator it;
    const vector<double>::const_iterator itIndex = (probability.begin() + currentIndex);

    for (it = probability.begin(); it != probability.end(); it++)
    {
        if ( it == itIndex )
            *it *= fma(wgt,alpha,1.0);
        else
            *it *= fma(-wgt,beta,1.0);
    }
}
Ejemplo n.º 11
0
inline double
OrderedTask::CalcMinTarget(const AircraftState &aircraft,
                           const GlidePolar &glide_polar,
                           const double t_target)
{
  if (stats.has_targets) {
    // only perform scan if modification is possible
    const auto t_rem = fdim(t_target, stats.total.time_elapsed);

    TaskMinTarget bmt(task_points, active_task_point, aircraft,
                      task_behaviour.glide, glide_polar,
                      t_rem, taskpoint_start);
    auto p = bmt.search(0);
    return p;
  }

  return 0;
}
Ejemplo n.º 12
0
void
CrossSectionRenderer::Paint(Canvas &canvas, const PixelRect rc) const
{
  DrawVerticalGradient(canvas, rc,
                       look.sky_color, look.background_color,
                       look.background_color);

  canvas.SetTextColor(look.text_color);
  canvas.Select(*look.grid_font);

  ChartRenderer chart(chart_look, canvas, rc);

  if (!vec.IsValid() || !start.IsValid()) {
    chart.DrawNoData(_("Not moving"));
    return;
  }

  const auto nav_altitude = gps_info.NavAltitudeAvailable()
    ? gps_info.nav_altitude
    : 0.;
  auto hmin = fdim(nav_altitude, 3300);
  auto hmax = std::max(3300., nav_altitude + 1000.);

  chart.ResetScale();
  chart.ScaleXFromValue(0);
  chart.ScaleXFromValue(vec.distance);
  chart.ScaleYFromValue(hmin);
  chart.ScaleYFromValue(hmax);

  TerrainHeight elevations[NUM_SLICES];
  UpdateTerrain(elevations);

  if (airspace_database != nullptr) {
    const AircraftState aircraft = ToAircraftState(Basic(), Calculated());
    airspace_renderer.Draw(canvas, chart, *airspace_database, start, vec,
                           aircraft);
  }

  terrain_renderer.Draw(canvas, chart, elevations);
  PaintGlide(chart);
  PaintAircraft(canvas, chart, rc);
  PaintGrid(canvas, chart);
}
Ejemplo n.º 13
0
void Adaptive::updateProbsAdvanced(const double wgt, \
                                   const vector<Flashcard> & cards)
{   // Updates probabilities
    double probUnasked = 0.0;
    const double pStar = probability[currentIndex];
    int numOfNumAskedIs0 = 0;
    double alpha = fdim(1.0,pStar), beta;
    double gamma = 0.01, gamWeight = 1.0;   // Experiment with different gammas

    for (usInt ii = 0; ii < probability.size(); ii++)
    {
        if (cards[ii].data.getNumAsked() == 0 && ii != currentIndex)
        {
            probUnasked += probability[ii];
            numOfNumAskedIs0++;
        }
    }

    // Divide-by-zero guard
    if (numOfNumAskedIs0 < (probability.size() - 2))
    {
        gamma = 0.01;
        beta = (gamma * probUnasked / wgt + pStar * alpha) / (alpha - probUnasked);
        gamWeight = 1.0;
    }
    else
    {
        beta = pStar;
        gamWeight = -wgt;
        gamma = beta;
    }

    for (usInt ii = 0; ii < probability.size(); ii++)
    {
        if ( ii == currentIndex )
            probability[ii] *= fma(wgt,alpha,1.0);
        else if ( cards[ii].data.getNumAsked() != 0 )
            probability[ii] *= fma(-wgt,beta,1.0);
        else
            probability[ii] *= fma(gamWeight,gamma,1.0);
    }
}
Ejemplo n.º 14
0
float fdimf (float x, float y)
{
	return (float) fdim( (double)x, (double)y );
}
Ejemplo n.º 15
0
static inline double abs_diff(double a, double b) {
    return fdim(a, b);
}
Ejemplo n.º 16
0
Archivo: math.c Proyecto: DeforaOS/libc
float fdimf(float x, float y)
{
	return fdim(x, y);
}
Ejemplo n.º 17
0
static void
F(compile_test) (void)
{
  TYPE a, b, c = 1.0;
  complex TYPE d;
  int i;
  int saved_count;
  long int j;
  long long int k;

  a = cos (cos (x));
  b = acos (acos (a));
  a = sin (sin (x));
  b = asin (asin (a));
  a = tan (tan (x));
  b = atan (atan (a));
  c = atan2 (atan2 (a, c), atan2 (b, x));
  a = cosh (cosh (x));
  b = acosh (acosh (a));
  a = sinh (sinh (x));
  b = asinh (asinh (a));
  a = tanh (tanh (x));
  b = atanh (atanh (a));
  a = exp (exp (x));
  b = log (log (a));
  a = log10 (log10 (x));
  b = ldexp (ldexp (a, 1), 5);
  a = frexp (frexp (x, &i), &i);
  b = expm1 (expm1 (a));
  a = log1p (log1p (x));
  b = logb (logb (a));
  a = exp2 (exp2 (x));
  b = log2 (log2 (a));
  a = pow (pow (x, a), pow (c, b));
  b = sqrt (sqrt (a));
  a = hypot (hypot (x, b), hypot (c, a));
  b = cbrt (cbrt (a));
  a = ceil (ceil (x));
  b = fabs (fabs (a));
  a = floor (floor (x));
  b = fmod (fmod (a, b), fmod (c, x));
  a = nearbyint (nearbyint (x));
  b = round (round (a));
  a = trunc (trunc (x));
  b = remquo (remquo (a, b, &i), remquo (c, x, &i), &i);
  j = lrint (x) + lround (a);
  k = llrint (b) + llround (c);
  a = erf (erf (x));
  b = erfc (erfc (a));
  a = tgamma (tgamma (x));
  b = lgamma (lgamma (a));
  a = rint (rint (x));
  b = nextafter (nextafter (a, b), nextafter (c, x));
  a = nextdown (nextdown (a));
  b = nexttoward (nexttoward (x, a), c);
  a = nextup (nextup (a));
  b = remainder (remainder (a, b), remainder (c, x));
  a = scalb (scalb (x, a), (TYPE) (6));
  k = scalbn (a, 7) + scalbln (c, 10l);
  i = ilogb (x);
  j = llogb (x);
  a = fdim (fdim (x, a), fdim (c, b));
  b = fmax (fmax (a, x), fmax (c, b));
  a = fmin (fmin (x, a), fmin (c, b));
  b = fma (sin (a), sin (x), sin (c));
  a = totalorder (totalorder (x, b), totalorder (c, x));
  b = totalordermag (totalordermag (x, a), totalordermag (c, x));

#ifdef TEST_INT
  a = atan2 (i, b);
  b = remquo (i, a, &i);
  c = fma (i, b, i);
  a = pow (i, c);
#endif
  x = a + b + c + i + j + k;

  saved_count = count;
  if (ccount != 0)
    ccount = -10000;

  d = cos (cos (z));
  z = acos (acos (d));
  d = sin (sin (z));
  z = asin (asin (d));
  d = tan (tan (z));
  z = atan (atan (d));
  d = cosh (cosh (z));
  z = acosh (acosh (d));
  d = sinh (sinh (z));
  z = asinh (asinh (d));
  d = tanh (tanh (z));
  z = atanh (atanh (d));
  d = exp (exp (z));
  z = log (log (d));
  d = sqrt (sqrt (z));
  z = conj (conj (d));
  d = fabs (conj (a));
  z = pow (pow (a, d), pow (b, z));
  d = cproj (cproj (z));
  z += fabs (cproj (a));
  a = carg (carg (z));
  b = creal (creal (d));
  c = cimag (cimag (z));
  x += a + b + c + i + j + k;
  z += d;

  if (saved_count != count)
    count = -10000;

  if (0)
    {
      a = cos (y);
      a = acos (y);
      a = sin (y);
      a = asin (y);
      a = tan (y);
      a = atan (y);
      a = atan2 (y, y);
      a = cosh (y);
      a = acosh (y);
      a = sinh (y);
      a = asinh (y);
      a = tanh (y);
      a = atanh (y);
      a = exp (y);
      a = log (y);
      a = log10 (y);
      a = ldexp (y, 5);
      a = frexp (y, &i);
      a = expm1 (y);
      a = log1p (y);
      a = logb (y);
      a = exp2 (y);
      a = log2 (y);
      a = pow (y, y);
      a = sqrt (y);
      a = hypot (y, y);
      a = cbrt (y);
      a = ceil (y);
      a = fabs (y);
      a = floor (y);
      a = fmod (y, y);
      a = nearbyint (y);
      a = round (y);
      a = trunc (y);
      a = remquo (y, y, &i);
      j = lrint (y) + lround (y);
      k = llrint (y) + llround (y);
      a = erf (y);
      a = erfc (y);
      a = tgamma (y);
      a = lgamma (y);
      a = rint (y);
      a = nextafter (y, y);
      a = nexttoward (y, y);
      a = remainder (y, y);
      a = scalb (y, (const TYPE) (6));
      k = scalbn (y, 7) + scalbln (y, 10l);
      i = ilogb (y);
      j = llogb (y);
      a = fdim (y, y);
      a = fmax (y, y);
      a = fmin (y, y);
      a = fma (y, y, y);
      a = totalorder (y, y);
      a = totalordermag (y, y);

#ifdef TEST_INT
      a = atan2 (i, y);
      a = remquo (i, y, &i);
      a = fma (i, y, i);
      a = pow (i, y);
#endif

      d = cos ((const complex TYPE) z);
      d = acos ((const complex TYPE) z);
      d = sin ((const complex TYPE) z);
      d = asin ((const complex TYPE) z);
      d = tan ((const complex TYPE) z);
      d = atan ((const complex TYPE) z);
      d = cosh ((const complex TYPE) z);
      d = acosh ((const complex TYPE) z);
      d = sinh ((const complex TYPE) z);
      d = asinh ((const complex TYPE) z);
      d = tanh ((const complex TYPE) z);
      d = atanh ((const complex TYPE) z);
      d = exp ((const complex TYPE) z);
      d = log ((const complex TYPE) z);
      d = sqrt ((const complex TYPE) z);
      d = pow ((const complex TYPE) z, (const complex TYPE) z);
      d = fabs ((const complex TYPE) z);
      d = carg ((const complex TYPE) z);
      d = creal ((const complex TYPE) z);
      d = cimag ((const complex TYPE) z);
      d = conj ((const complex TYPE) z);
      d = cproj ((const complex TYPE) z);
    }
}
Ejemplo n.º 18
0
void
domath  (void)
{
#ifndef NO_DOUBLE
  double f1;
  double f2;

  int i1;

  f1 = acos (0.0);
  fprintf( stdout, "acos           : %f\n", f1);

  f1 = acosh (0.0);
  fprintf( stdout, "acosh          : %f\n", f1);

  f1 = asin (1.0);
  fprintf( stdout, "asin           : %f\n", f1);

  f1 = asinh (1.0);
  fprintf( stdout, "asinh          : %f\n", f1);

  f1 = atan (M_PI_4);
  fprintf( stdout, "atan           : %f\n", f1);

  f1 = atan2 (2.3, 2.3);
  fprintf( stdout, "atan2          : %f\n", f1);

  f1 = atanh (1.0);
  fprintf( stdout, "atanh          : %f\n", f1);

  f1 = cbrt (27.0);
  fprintf( stdout, "cbrt           : %f\n", f1);

  f1 = ceil (3.5);
  fprintf( stdout, "ceil           : %f\n", f1);

  f1 = copysign (3.5, -2.5);
  fprintf( stdout, "copysign       : %f\n", f1);

  f1 = cos (M_PI_2);
  fprintf( stdout, "cos            : %f\n", f1);

  f1 = cosh (M_PI_2);
  fprintf( stdout, "cosh           : %f\n", f1);

  f1 = erf (42.0);
  fprintf( stdout, "erf            : %f\n", f1);

  f1 = erfc (42.0);
  fprintf( stdout, "erfc           : %f\n", f1);

  f1 = exp (0.42);
  fprintf( stdout, "exp            : %f\n", f1);

  f1 = exp2 (0.42);
  fprintf( stdout, "exp2           : %f\n", f1);

  f1 = expm1 (0.00042);
  fprintf( stdout, "expm1          : %f\n", f1);

  f1 = fabs (-1.123);
  fprintf( stdout, "fabs           : %f\n", f1);

  f1 = fdim (1.123, 2.123);
  fprintf( stdout, "fdim           : %f\n", f1);

  f1 = floor (0.5);
  fprintf( stdout, "floor          : %f\n", f1);
  f1 = floor (-0.5);
  fprintf( stdout, "floor          : %f\n", f1);

  f1 = fma (2.1, 2.2, 3.01);
  fprintf( stdout, "fma            : %f\n", f1);

  f1 = fmax (-0.42, 0.42);
  fprintf( stdout, "fmax           : %f\n", f1);

  f1 = fmin (-0.42, 0.42);
  fprintf( stdout, "fmin           : %f\n", f1);

  f1 = fmod (42.0, 3.0);
  fprintf( stdout, "fmod           : %f\n", f1);

  /* no type-specific variant */
  i1 = fpclassify(1.0);
  fprintf( stdout, "fpclassify     : %d\n", i1);

  f1 = frexp (42.0, &i1);
  fprintf( stdout, "frexp          : %f\n", f1);

  f1 = hypot (42.0, 42.0);
  fprintf( stdout, "hypot          : %f\n", f1);

  i1 = ilogb (42.0);
  fprintf( stdout, "ilogb          : %d\n", i1);

  /* no type-specific variant */
  i1 = isfinite(3.0);
  fprintf( stdout, "isfinite       : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreater(3.0, 3.1);
  fprintf( stdout, "isgreater      : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreaterequal(3.0, 3.1);
  fprintf( stdout, "isgreaterequal : %d\n", i1);

  /* no type-specific variant */
  i1 = isinf(3.0);
  fprintf( stdout, "isinf          : %d\n", i1);

  /* no type-specific variant */
  i1 = isless(3.0, 3.1);
  fprintf( stdout, "isless         : %d\n", i1);

  /* no type-specific variant */
  i1 = islessequal(3.0, 3.1);
  fprintf( stdout, "islessequal    : %d\n", i1);

  /* no type-specific variant */
  i1 = islessgreater(3.0, 3.1);
  fprintf( stdout, "islessgreater  : %d\n", i1);

  /* no type-specific variant */
  i1 = isnan(0.0);
  fprintf( stdout, "isnan          : %d\n", i1);

  /* no type-specific variant */
  i1 = isnormal(3.0);
  fprintf( stdout, "isnormal       : %d\n", i1);

  /* no type-specific variant */
  f1 = isunordered(1.0, 2.0);
  fprintf( stdout, "isunordered    : %d\n", i1);

  f1 = j0 (1.2);
  fprintf( stdout, "j0             : %f\n", f1);

  f1 = j1 (1.2);
  fprintf( stdout, "j1             : %f\n", f1);

  f1 = jn (2,1.2);
  fprintf( stdout, "jn             : %f\n", f1);

  f1 = ldexp (1.2,3);
  fprintf( stdout, "ldexp          : %f\n", f1);

  f1 = lgamma (42.0);
  fprintf( stdout, "lgamma         : %f\n", f1);

  f1 = llrint (-0.5);
  fprintf( stdout, "llrint         : %f\n", f1);
  f1 = llrint (0.5);
  fprintf( stdout, "llrint         : %f\n", f1);

  f1 = llround (-0.5);
  fprintf( stdout, "lround         : %f\n", f1);
  f1 = llround (0.5);
  fprintf( stdout, "lround         : %f\n", f1);

  f1 = log (42.0);
  fprintf( stdout, "log            : %f\n", f1);

  f1 = log10 (42.0);
  fprintf( stdout, "log10          : %f\n", f1);

  f1 = log1p (42.0);
  fprintf( stdout, "log1p          : %f\n", f1);

  f1 = log2 (42.0);
  fprintf( stdout, "log2           : %f\n", f1);

  f1 = logb (42.0);
  fprintf( stdout, "logb           : %f\n", f1);

  f1 = lrint (-0.5);
  fprintf( stdout, "lrint          : %f\n", f1);
  f1 = lrint (0.5);
  fprintf( stdout, "lrint          : %f\n", f1);

  f1 = lround (-0.5);
  fprintf( stdout, "lround         : %f\n", f1);
  f1 = lround (0.5);
  fprintf( stdout, "lround         : %f\n", f1);

  f1 = modf (42.0,&f2);
  fprintf( stdout, "lmodf          : %f\n", f1);

  f1 = nan ("");
  fprintf( stdout, "nan            : %f\n", f1);

  f1 = nearbyint (1.5);
  fprintf( stdout, "nearbyint      : %f\n", f1);

  f1 = nextafter (1.5,2.0);
  fprintf( stdout, "nextafter      : %f\n", f1);

  f1 = pow (3.01, 2.0);
  fprintf( stdout, "pow            : %f\n", f1);

  f1 = remainder (3.01,2.0);
  fprintf( stdout, "remainder      : %f\n", f1);

  f1 = remquo (29.0,3.0,&i1);
  fprintf( stdout, "remquo         : %f\n", f1);

  f1 = rint (0.5);
  fprintf( stdout, "rint           : %f\n", f1);
  f1 = rint (-0.5);
  fprintf( stdout, "rint           : %f\n", f1);

  f1 = round (0.5);
  fprintf( stdout, "round          : %f\n", f1);
  f1 = round (-0.5);
  fprintf( stdout, "round          : %f\n", f1);

  f1 = scalbln (1.2,3);
  fprintf( stdout, "scalbln        : %f\n", f1);

  f1 = scalbn (1.2,3);
  fprintf( stdout, "scalbn         : %f\n", f1);

  /* no type-specific variant */
  i1 = signbit(1.0);
  fprintf( stdout, "signbit        : %i\n", i1);

  f1 = sin (M_PI_4);
  fprintf( stdout, "sin            : %f\n", f1);

  f1 = sinh (M_PI_4);
  fprintf( stdout, "sinh           : %f\n", f1);

  f1 = sqrt (9.0);
  fprintf( stdout, "sqrt           : %f\n", f1);

  f1 = tan (M_PI_4);
  fprintf( stdout, "tan            : %f\n", f1);

  f1 = tanh (M_PI_4);
  fprintf( stdout, "tanh           : %f\n", f1);

  f1 = tgamma (2.1);
  fprintf( stdout, "tgamma         : %f\n", f1);

  f1 = trunc (3.5);
  fprintf( stdout, "trunc          : %f\n", f1);

  f1 = y0 (1.2);
  fprintf( stdout, "y0             : %f\n", f1);

  f1 = y1 (1.2);
  fprintf( stdout, "y1             : %f\n", f1);

  f1 = yn (3,1.2);
  fprintf( stdout, "yn             : %f\n", f1);
#endif
}
Ejemplo n.º 19
0
TEST(math, fdim) {
  ASSERT_FLOAT_EQ(0.0, fdim(1.0, 1.0));
  ASSERT_FLOAT_EQ(1.0, fdim(2.0, 1.0));
  ASSERT_FLOAT_EQ(0.0, fdim(1.0, 2.0));
}
Ejemplo n.º 20
0
__device__ void double_precision_math_functions() {
    int iX;
    double fX, fY;

    acos(1.0);
    acosh(1.0);
    asin(0.0);
    asinh(0.0);
    atan(0.0);
    atan2(0.0, 1.0);
    atanh(0.0);
    cbrt(0.0);
    ceil(0.0);
    copysign(1.0, -2.0);
    cos(0.0);
    cosh(0.0);
    cospi(0.0);
    cyl_bessel_i0(0.0);
    cyl_bessel_i1(0.0);
    erf(0.0);
    erfc(0.0);
    erfcinv(2.0);
    erfcx(0.0);
    erfinv(1.0);
    exp(0.0);
    exp10(0.0);
    exp2(0.0);
    expm1(0.0);
    fabs(1.0);
    fdim(1.0, 0.0);
    floor(0.0);
    fma(1.0, 2.0, 3.0);
    fmax(0.0, 0.0);
    fmin(0.0, 0.0);
    fmod(0.0, 1.0);
    frexp(0.0, &iX);
    hypot(1.0, 0.0);
    ilogb(1.0);
    isfinite(0.0);
    isinf(0.0);
    isnan(0.0);
    j0(0.0);
    j1(0.0);
    jn(-1.0, 1.0);
    ldexp(0.0, 0);
    lgamma(1.0);
    llrint(0.0);
    llround(0.0);
    log(1.0);
    log10(1.0);
    log1p(-1.0);
    log2(1.0);
    logb(1.0);
    lrint(0.0);
    lround(0.0);
    modf(0.0, &fX);
    nan("1");
    nearbyint(0.0);
    nextafter(0.0, 0.0);
    fX = 1.0;
    norm(1, &fX);
    norm3d(1.0, 0.0, 0.0);
    norm4d(1.0, 0.0, 0.0, 0.0);
    normcdf(0.0);
    normcdfinv(1.0);
    pow(1.0, 0.0);
    rcbrt(1.0);
    remainder(2.0, 1.0);
    remquo(1.0, 2.0, &iX);
    rhypot(0.0, 1.0);
    rint(1.0);
    fX = 1.0;
    rnorm(1, &fX);
    rnorm3d(0.0, 0.0, 1.0);
    rnorm4d(0.0, 0.0, 0.0, 1.0);
    round(0.0);
    rsqrt(1.0);
    scalbln(0.0, 1);
    scalbn(0.0, 1);
    signbit(1.0);
    sin(0.0);
    sincos(0.0, &fX, &fY);
    sincospi(0.0, &fX, &fY);
    sinh(0.0);
    sinpi(0.0);
    sqrt(0.0);
    tan(0.0);
    tanh(0.0);
    tgamma(2.0);
    trunc(0.0);
    y0(1.0);
    y1(1.0);
    yn(1, 1.0);
}
Ejemplo n.º 21
0
int main(int argc, char *argv[])
{
  double x = 0.0;
  if (argv) x = fdim((double) argc, (double) argc);
  return 0;
}
Ejemplo n.º 22
0
void
math (double d, int *ex, double *dp)
{
  acos (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 8 } */
  acosh (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 10 } */
  asin (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 12 } */
  asinh (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 14 } */
  atan (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 16 } */
  atanh (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 18 } */
  atan2 (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 20 } */
  cbrt (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 22 } */
  ceil (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 24 } */
  copysign (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 26 } */
  cos (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 28 } */
  cosh (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 30 } */
  erf (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 32 } */
  erfc (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 34 } */
  exp (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 36 } */
  exp2 (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 38 } */
  expm1 (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 40 } */
  fabs (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 42 } */
  fdim (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 44 } */
  floor (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 46 } */
  fma (d, d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 48 } */
  fmax (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 50 } */
  fmin (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 52 } */
  fmod (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 54 } */
  frexp (d, ex); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 56 } */
  hypot (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 58 } */
  /* We don't generate the warning for ilogb.  */
  ilogb (d);
  ldexp (d, *ex); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 62 } */
  lgamma (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 64 } */
  llrint (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 66 } */
  llround (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 68 } */
  log (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 70 } */
  log10 (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 72 } */
  log1p (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 74 } */
  log2 (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 76 } */
  logb (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 78 } */
  lrint (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 80 } */
  lround (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 82 } */
  modf (d, dp); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 84 } */
  nan (""); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 86 } */
  nearbyint (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 88 } */
  nextafter (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 90 } */
  nexttoward (d, 20.0L); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 92 } */
  pow (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 94 } */
  remainder (d, d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 96 } */
  remquo (d, d, ex); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 98 } */
  rint (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 100 } */
  round (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 102 } */
  scalbln (d, 100L); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 104 } */
  scalbn (d, 100); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 106 } */
  sin (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 108 } */
  sinh (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 110 } */
  sincos (d, dp, dp); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 112 } */
  sqrt (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 114 } */
  tan (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 116 } */
  tanh (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 118 } */
  tgamma (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 120 } */
  trunc (d); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..math.h.." "" { target *-*-* } 122 } */
}
Ejemplo n.º 23
0
TEST(math, fdim) {
  ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 1.0));
  ASSERT_DOUBLE_EQ(1.0, fdim(2.0, 1.0));
  ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 2.0));
}
Ejemplo n.º 24
0
long double fdiml (long double x, long double y)
{
	return (long double) fdim( (double)x, (double)y );
}
Ejemplo n.º 25
0
int main()
{
	int choice,  res,  no1, no2, ch;
	double n, m, s1, s2, res1, ans, val, num;
	float x, y;
	double result = 0, n1 = 0, fradecimal;
	long y1;
	char c;
	char frabinary[100], hexa[MAX];
	long int binaryval;
	div_t1 temp;
	poly * poly1, * poly2, * poly3;
	FILE *fp;
	printf("\n\n....NEW USER FIRST READ THE MANUAL TEXT FILE TO UNDERSTANS THE FUNCTIONS USAGE....\n\n");
	while(1) {
		printmenu1();
		printf("Enter your choice\n");
		scanf("%d", &ch);
		switch(ch) {
			case 1:
			
				fp = fopen("Manual.txt", "r");
				if(!fp)
					printf("Cannot open file\n");
				while((c = fgetc(fp) )!= EOF)
					printf("%c", c);
					fclose(fp);
				break;
			case 2:
				while(1) {
					printmenu();
					printf("Enter your choice\n");
					scanf("%d" ,&choice);
					switch(choice) {
						case 1:
							printf(".....sqrt() function finds the square root of a number.....\n");	
							printf("Enter your number:\n");
							scanf("%lf", &n);
							m = sqrt(n); //square root
							if( m == 0) {
								printf(" You entered negative number\n");
								break;				
							}
							printf("square root is %.3lf\n", m);
							waita();
							break;
						case 2:
							printf(".....mod() finds remainder when one number is divided 									by 2nd 	number.....\n"); 
						
							printf("enter the number to be divided :\t\n");
							scanf("%lf",&s1);
							printf("enter the divisor:\t\n");
							scanf("%lf",&s2);
							ans = fmod(s1, s2); //remainder
							printf("remainder is : %lf\n", ans);
							waita();
							break;
						case 3:
							printf(".....fabs()  finds the absolute value of floating 									point number.....\n");
						
							printf("Enter the number to find the absolute value\n");
							scanf("%lf", &val);
							res1 = fabs(val);  //absolute value
							printf("The absolute value of %lf is %lf\n", val, res1);
							waita();
							break;
						case 4:
							printf(".....ceilx() function finds ceil value of a 									number.....\n");	
							printf("Enter the value\n");
							scanf("%lf", &val);
							ans = ceilx(val); //ceil function
							printf("Value=%lf\n", ans);
							waita();
							break;   
 	
						case 5:
							printf(".....floorx() function finds floor value of a 										number.....\n");	
							printf("Enter the value\n");
							scanf("%lf", &val);
   							ans = floorx(val); //floor function
							printf("Value=%lf\n", ans);
							waita();
							break;
						case 6:
							printf(".....expoential() function finds expoential value of a 									number 	i.e. e^x.....\n");
							printf("Enter the value of x\n");
    							scanf("%lf", &n);
   						        printf("e^x = %lf\n", exponential(n)); //exponential function
							waita();
							break;
						case 7:
							printf(".....hypot()finds the value of hypotenuse when two 									sides are given.....\n");
							
							printf("Enter sides: \n");
							scanf ("%lf %lf",&s1,&s2);
							printf("Hypotenus of %f %f is: %f\n", s1, s2,hypot(s1,s2)); 								//hypotenuse function
							waita();
							break;
						case 8: 
							printf(".....cbrt() finds the cube root of proper number i.e. 									cbrt(8)= 2.....\n"); 
						 
							printf("enter the number to find the cube root\n");
 							scanf("%lf",&n1);
 							if(n1 < 0) {
 	
 								 printf("enter only +ve integer value\n");
						  		 waita();
 								 break;
 							}
 							result = cbrtx(n1); //cube root function
 							if(result)
 								 printf("cube root of %lf is %lf\n",n1,result);
 								else {
								printf("not a proper value for finding the cube 										root\n");
								waita();
 								break;
							}	
							
							waita();
							break;
						case 9:
							printf(".....pow() function finds the x^y power.....\n");
							printf("Enter the number and the power\n");
							scanf("%lf%lf", &s1, &s2);
							res1 = Pow(s1, s2); //power function
							printf("The %lf^%lf is %lf\n", s1, s2, res1);
							
							waita();
							break;
						case 10:
							printf(".....trunc() function truncates the floating 									points.....\n");	
							printf("Enter the value for truncating\n");
							scanf("%lf", &s1);
							res1 = trunc(s1); // truncating a number
							printf("The value after truncating is %lf\n", res1);
							
							waita();
							break;
						case 11:
							printf(".....round() function rounds up a floating point 									number..... \n");
							printf("Enter the value for rounding\n");
							scanf("%lf", &s1);
							res1 = round(s1); //rounding a number
							printf("The value after rounding is %lf\n", res1);
							
							waita();
							break;
						case 12:
							printf(".....abs() function finds absolute value of integer 									number.....\n");
							printf("Enter the integer number to find the absolute value\n");
							scanf("%lf", &n);
							if(n - (int)n == 0) {
								res = abs(n);  //absolute value
								printf("The absolute value of %lf is %d\n", n, res);
								waita();
								break;
							}
							else {
								printf("Enter integer number\n");
								waita();
								break;
							}
							waita();
							break;
						case 13:
							printf(".....fmax() function finds maximum between two 									numbers.....\n");	
							printf("Enter two numbers to find maximun number\n");	
							scanf("%lf%lf", &s1, &s2);
							res1 = fmax(s1,s2);
							printf("The max number is %f\n",res1);
							waita();
							break;
						case 14:
							printf(".....fmin() function finds minimum between two 									numbers.....\n");	
							printf("Enter two numbers to find minimum number\n");	
							scanf("%lf%lf", &s1, &s2);
							res1 = fmin(s1,s2);
							printf("The min number is %f\n",res1);
							waita();
							break;
						case 15:
							printf(".....fdim()finds +ve difference bet^n 2 no's & if fails 									it returns 0.....\n"); 
						
							printf("Enter two numbers to find difference of two numbers\n");
							scanf("%lf%lf", &s1, &s2);
							res1 = fdim(s1,s2);
							if(res1 == 0) {
								printf("This functions returns 0 when  first number is 										less than or equal to second number\n");
								waita();
								break;
							}		
							printf("The positive Difference  is %f\n",res1);
							waita();
							break;
						case 16:
							printf(".....roundf() function rounds up a floating 										value.....		\n");	
							printf("Enter the value for rounding\n");
							scanf("%f", &x);
							y = roundf(x);
							printf("The value after rounding is %f\n", y);
							waita();
							break;
						case 17:
							printf(".....lround() function rounds up a long value.....\n");
							printf("Enter the value for rounding\n");
							scanf("%lf", &n);
							y1 = lround(n);
							printf("The value after rounding is %li\n", y1);
							waita();
							break;
						case 18:
							printf(".....add_poly() function adds two polynomials.....\n");
							printf("\nCreate 1st expression\n");
							create(&poly1);
							printf("\nStored the 1st expression");
							show(poly1);
		
							printf("\nCreate 2nd expression\n");
							create(&poly2);
							printf("\nStored the 2nd expression");
							show(poly2);
						
							add_poly(&poly3, poly1, poly2);
							show(poly3);
							waita();
							break;
						case 19:
							printf(".....sub_poly() function subtract two 											polynomials.....		\n");	
							printf("\nCreate 1st expression\n");
							create(&poly1);
							printf("\nStored the 1st expression");
							show(poly1);	
							printf("\nCreate 2nd expression\n");
							create(&poly2);
							printf("\nStored the 2nd expression");
							show(poly2);
	
							sub_poly(&poly3, poly1, poly2);
							show(poly3);
							waita();
							break;
						case 20:
							printf(".....division() function givesquotient and remainder 									after division.....\n");
							printf("Enter divident\n");
							scanf("%d", &no1);
							printf("Enter divisor\n");
							scanf("%d", &no2);
							temp = division(no1, no2);
							printf("quotient=%d\tremainder=%d\n", temp.quot, temp.rem);
							waita();
							break;			
						case 21:
							printf(".....ldexp() function returns value * 									2^expoential.....		\n");
							printf("Enter the value\n");
							scanf("%lf", &n);
							printf("Enter the integer exponent\n");
							scanf("%d", &no1);
							m = ldexp(n, no1);
							printf("value=%lf\n", m);	
							waita();
							break;;
						case 22:
							printf(".....exp2() function returns 2^expoential.....\n");
							printf("Enter the expoential\n");
							scanf("%lf", &n);
							m = exp2(n);
							printf("exp2(%lf)=%lf\n", n, m);
							waita();
							break;
						case 23:
							printf(".....tgamma() fuction calculates gamma value.....\n");
							printf("Enter the number to find gamma value\n");
							scanf("%lf", &num);
							if( num <= 0) {
								printf("Gamma of negative number and 0 is not 										defined		\n");	
								waita();
								break;
							}
							ans = tgamma(num);
							printf("gamma(%lf)=%lf\n", num, ans);
							waita();
							break;			
						case 24:
							printf(".....fact() function returns factorial of a 										number.....		\n");	
							printf("Enter number to find factorial\n");
							scanf("%lf", &n);
							ans = fact(n);
							printf("The factorial of %lf is %lf\n", n, ans);
							waita();
							break;
						case 25:
							printf(".....square() function calculates square of a 									number.....\n");	
							printf("Enter number to find square of entered number\n");
							scanf("%lf", &n);
							ans = square(n);
							printf("The square of %lf is %lf\n",n, ans);
							waita();
							break;
						case 26:
							printf(".....cube() function calculates cube of a 									number.....		\n");	
							printf("Enter number to find cube of a entered number\n");
							scanf("%lf", &n);
							ans = cube(n);
							printf("The cube of %lf is %lf\n",n, ans);
							
							waita();
							break;
						case 27:
							printf("dec_bin() function converts decimal number into 								binary			\n");
							printf("Enter any fractional Decimal number\n");
							scanf("%lf", &fradecimal);
							printf("eduivalent binary value is %lf\n",dec_bin(fradecimal));
							waita();
							break;
						case 28:
							printf("bin_dec() function converts binary number into 								decimal 		\n");
							printf("Enter any fractional Binary number\n");
							scanf("%s", frabinary);
							printf("eduivalent decimal value is %lf\n",bin_dec(frabinary));
							waita();
							break;
						case 29:
							printf("This fun. converts decimal number to octal number\n");
							printf("Enter a decimal number:\n ");
       							scanf("%d", &no1);
       							printf("%d in decimal = %d in octal\n", no1, 									decimal_octal(no1));	
							waita();
							break;
						case 30:
							printf("This fun. converts octal number to decimal number\n");
							printf("Enter a octal number:\n ");
       							scanf("%d", &no1);
       							printf("%d in octal = %d in decimal\n", no1, 									decimal_octal(no1));	
							waita();
							break;
						case 31:
							printf("This fun. converts binary number to octal number\n");
							printf("Enter a binary number:\n ");
       							scanf("%d",&no1);
        						printf("%d in binary = %d in octal\n", no1, binary_octal(no1));
							waita();
							break;
						case 32:
							printf("This fun. converts octal number to binary number\n");
							printf("Enter a octal number:\n ");
        						scanf("%d",&no1);
        						printf("%d in octal = %d in binary\n",no1, octal_binary(no1));
							waita();
   
							break;
						case 33:
							printf("This function converts binary into hex number\n");
							printf("Enter the binary number:\n ");
    							scanf("%ld", &binaryval);
    
    							printf("Equivalent hexadecimal value: %lX\n", 									binary_hex(binaryval));
							waita();
							break;
						case 34:
							printf("This function converts hex into binary number\n");
							printf("Enter the value for hexadecimal\n ");
    							scanf("%s", hexa);
   							hex_binary(hexa);
							waita();
							break;
						case 35:
							return 0;
						default:
							printf(".....wrong choice.....\n");
					}	
				}	
			case 3:	
				return 0;
			default:
				printf("Invalid Choice\n");
			}	
			
		} 
		return 0;		
	}		
Ejemplo n.º 26
0
Archivo: ld64.c Proyecto: X0rg/darling
double fdiml( double x, double y ) {
    return (double)fdim((double) x, (double) y);
}