Example #1
0
static void
update_range_lables(GtkWidget *from, GtkWidget *to, GtkWidget *unit,
                    gdouble min, gdouble max, const gchar *unitstring)
{
    GwySIValueFormat *vf;
    GwySIUnit *siunit;
    gint power10;
    gchar *s;

    siunit = gwy_si_unit_new_parse(unitstring, &power10);
    min *= pow10(power10);
    max *= pow10(power10);
    vf = gwy_si_unit_get_format_with_digits(siunit, GWY_SI_UNIT_FORMAT_VFMARKUP,
                                            MAX(fabs(min), fabs(max)), 3,
                                            NULL);
    s = g_strdup_printf("%.*f", vf->precision, min/vf->magnitude);
    gtk_label_set_markup(GTK_LABEL(from), s);
    g_free(s);
    s = g_strdup_printf("%.*f", vf->precision, max/vf->magnitude);
    gtk_label_set_markup(GTK_LABEL(to), s);
    g_free(s);
    gtk_label_set_markup(GTK_LABEL(unit), vf->units);
    gwy_si_unit_value_format_free(vf);
    g_object_unref(siunit);
}
Example #2
0
File: ftoa.c Project: npe9/harvey
/*
 * convert floating to ascii.  ftoa returns an integer e such that
 * f=g*10**e, with .1<=|g|<1 (e=0 when g==0) and puts an ascii
 * representation of g in the buffer pointed to by bp.  bp[0] will
 * be '+' or '-', and bp[1] to bp[NFTOA-2]
 * will be appropriate digits of g. bp[NFTOA-1] will be '\0'
 */
int ftoa(double f, char *bp) {
    int e, e1, e2, i;
    double digit, g, p;
    if(f>=0) *bp++='+';
    else {
        f=-f;
        *bp++='-';
    }
    /* find e such that f==0 or 1<=f*pow10(e)<10, and set f=f*pow10(e) */
    if(f==0.) e=1;
    else {
        frexp(f, &e);
        e=-e*30103/100000;
        /* split in 2 pieces to guard against overflow in extreme cases */
        e1=e/2;
        e2=e-e1;
        p=f*pow10(e2);
        while((g=p*pow10(e1))<1.) e1++;
        while((g=p*pow10(e1))>=10.) --e1;
        e=e1+e2;
        f=g;
    }
    for(i=0; i!=NDIG; i++) {
        f=modf(f, &digit)*10.;
        *bp++=digit+'0';
    }
    *bp='\0';
    return 1-e;
}
Example #3
0
void main (void)
 {
   printf("10 raised to -1 is %f\n", pow10(-1));
   printf("10 raised to 0 is %f\n", pow10(0));
   printf("10 raised to 1 is %f\n", pow10(1));
   printf("10 raised to 2 is %f\n", pow10(2));
}
cons_t* parse_exact_real(const char* sc, int radix)
{
  if ( radix != 10 )
    raise(parser_exception(
      "Only reals with decimal radix are supported"));

  /*
   * Since the real is already in string form, we can simply turn it into a
   * rational number.
   */
  char *s = strdup(sc);
  char *d = strchr(s, '.');
  *d = '\0';
  const char* left = s;
  const char* right = d+1;

  int decimals = strlen(right);

  /*
   * NOTE: If we overflow here, we're in big trouble.
   * TODO: Throw an error if we overflow.  Or just implement bignums.
   */
  rational_t r;
  r.numerator = to_i(left, radix)*pow10(decimals) + to_i(right, radix);
  r.denominator = pow10(decimals);

  free(s);
  return rational(r, true);
}
Example #5
0
int reverse(int x){
  int keta = 1 + (int)log10(x);
  int i,y=0;
  for( i=0; i<keta; i++){
    y += (int)(x / pow10(i)) % 10 * pow10(keta-i-1);
  }
  //  printf("x:%d keta:%d, y:%d, test:%d",x,keta,y,pow10(2));
  return y;
}
Example #6
0
static void
fix_scales(EZDSection *section,
           gint idx,
           GwyContainer *container)
{
    GwyDataField *dfield;
    GwySIUnit *siunit;
    gchar key[40];
    gint power10;
    gdouble r;

    g_snprintf(key, sizeof(key), "/%d/data", idx);
    dfield = GWY_DATA_FIELD(gwy_container_get_object_by_name(container, key));

    /* Fix value scale */
    siunit = gwy_si_unit_new_parse(section->zrange.unit, &power10);
    gwy_data_field_set_si_unit_z(dfield, siunit);
    g_object_unref(siunit);
    r = pow10(power10);
    gwy_data_field_multiply(dfield, r*section->zrange.range);
    gwy_data_field_add(dfield, r*section->zrange.min);

    /* Fix lateral scale */
    siunit = gwy_si_unit_new_parse(section->xrange.unit, &power10);
    gwy_data_field_set_si_unit_xy(dfield, siunit);
    g_object_unref(siunit);
    gwy_data_field_set_xreal(dfield, pow10(power10)*section->xrange.range);

    siunit = gwy_si_unit_new_parse(section->yrange.unit, &power10);
    gwy_data_field_set_yreal(dfield, pow10(power10)*section->yrange.range);
    g_object_unref(siunit);

    /* Some metadata */
    if (section->zrange.name) {
        const gchar *s;

        switch (section->direction) {
            case SCAN_FORWARD:
            s = " forward";
            break;

            case SCAN_BACKWARD:
            s = " backward";
            break;

            default:
            s = "";
            break;
        }
        g_snprintf(key, sizeof(key), "/%d/data/title", idx);
        gwy_container_set_string_by_name(container, key,
                                         g_strdup_printf("%s%s",
                                                         section->zrange.name,
                                                         s));
    }
}
Example #7
0
// Same as getFirst32, but k = [0..MAXDIGITS_INT128] = [0..38]
_uint128 &BigReal::getFirst128(_uint128 &dst, const UINT k, BRExpoType *scale) const {
#ifdef _DEBUG
  DEFINEMETHODNAME;
  if(k > MAXDIGITS_INT128) {
    throwBigRealInvalidArgumentException(method, _T("k=%d. Legal interval is [0..%d]"),k,MAXDIGITS_INT128);
  }
#endif

  const Digit *p = m_first;
  if(p == NULL) {
    if(scale) *scale = 0;
    dst = 0;
    return dst;
  }

  int              tmpScale = 0;
  dst                       = p->n;
  int              digits   = getDecimalDigitCount(p->n), firstDigits = digits;
  if((UINT)digits >= k) {
    dst /= pow10(digits-k); // digits-k <= LOG10_BIGREALBASE, so pow10 will not fail
    if(scale) {
      ADJUSTSCALEMOD10(dst);
    }
  } else { // digits < k
    if(scale) {
      for(p = p->next; (UINT)digits < k; digits += LOG10_BIGREALBASE) {
        if(p) {
          const BRDigitType p10 = pow10(min(LOG10_BIGREALBASE,k-digits));
          dst = dst * p10 + p->n / (BIGREALBASE/p10);
          p = p->next;
        } else {
          tmpScale = k - digits;
          break;
        }
      }
      ADJUSTSCALEMOD10(dst);
    } else { // scale == NULL
      for(p = p->next; (UINT)digits < k; digits += LOG10_BIGREALBASE) {
        const BRDigitType p10 = pow10(min(LOG10_BIGREALBASE,k-digits));
        dst *= p10;
        if(p) {
          dst += p->n / (BIGREALBASE/p10);
          p = p->next;
        }
      }
    }
  }

  if(scale) {
    *scale  = m_expo * LOG10_BIGREALBASE + firstDigits - 1 + tmpScale - k;
  }
  return dst;
}
Example #8
0
static GwyDataField*
rhkspm32_read_data(RHKPage *rhkpage)
{
    GwyDataField *dfield;
    const guint16 *p;
    GwySIUnit *siunit;
    gdouble *data;
    const gchar *s;
    gdouble q;
    gint power10;
    guint i, j, xres, yres;

    p = (const guint16*)(rhkpage->buffer + rhkpage->data_offset);
    xres = rhkpage->xres;
    yres = rhkpage->yres;
    // the scales are no longer gurunteed to be positive,
    // so they must be "fixed" here (to enable spectra)
    dfield = gwy_data_field_new(xres, yres,
                                xres*fabs(rhkpage->x.scale),
                                yres*fabs(rhkpage->y.scale),
                                FALSE);

    data = gwy_data_field_get_data(dfield);
    for (i = 0; i < yres; i++) {
        for (j = 0; j < xres; j++)
            data[i*xres + xres-1 - j] = GINT16_FROM_LE(p[i*xres + j]);
    }

    siunit = gwy_data_field_get_si_unit_xy(dfield);
    gwy_si_unit_set_from_string_parse(siunit, rhkpage->x.units, &power10);
    if (power10) {
        q = pow10(power10);
        gwy_data_field_set_xreal(dfield, q*gwy_data_field_get_xreal(dfield));
        gwy_data_field_set_yreal(dfield, q*gwy_data_field_get_yreal(dfield));
    }

    siunit = gwy_data_field_get_si_unit_z(dfield);
    s = rhkpage->z.units;
    /* Fix some silly units */
    if (gwy_strequal(s, "N/sec"))
        s = "s^-1";
    gwy_si_unit_set_from_string_parse(siunit, s, &power10);
    q = pow10(power10);

    gwy_data_field_multiply(dfield, q*fabs(rhkpage->z.scale));
    gwy_data_field_add(dfield, q*rhkpage->z.offset);

    return dfield;
}
Example #9
0
int main()
{
	int i, stage;
	int level;
	int success = 0;
	clock_t start, end;

	srand((unsigned long)time(NULL));

	printf("数値記憶トレーニング\n");

	do {
		printf("挑戦するレベル (%d ~ %d): ", LEVEL_MIN, LEVEL_MAX);
		scanf("%d", &level);
	} while (level < LEVEL_MIN || level > LEVEL_MAX);

	start = clock();
	for (stage = 0; stage < MAX_STAGE; stage++) {
		int ans;
		int input;

		ans = pow10(level-1) + rand() % (pow10(level-1) * 9);

		printf("%d", ans);
		fflush(stdout);
		sleep(125*level);

		int pos = rand() % level;

		printf("\r%*s\r%d 桁目は? 入力: ", level, " ", pos+1);
		scanf("%d", &input);

		if (get_onenum(ans, pos, level) != input) 
			printf("不正解です\n");
		else {
			printf("正解です\n");
			success++;
		}
	}

	end = clock();

	printf("終了\n");
	printf("正答率: %3.2f (%d / %d)\n", (double)(success * 100/MAX_STAGE), success, MAX_STAGE);
	printf("経過時間: %f\n", (double)(end - start)/CLOCKS_PER_SEC);

	return 0;

}
Example #10
0
void AmplitudeWidget::drawVerticalRefLines()
{
  //Draw the vertical reference lines
  double timeStep = timeWidth() / double(width()) * 150.0; //time per 150 pixels
  double timeScaleBase = pow10(floor(log10(timeStep))); //round down to the nearest power of 10

  //choose a timeScaleStep which is a multiple of 1, 2 or 5 of timeScaleBase
  int largeFreq;
  if(timeScaleBase * 5.0 < timeStep) { largeFreq = 5; }
  else if (timeScaleBase * 2.0 < timeStep) { largeFreq = 2; }
  else { largeFreq = 2; timeScaleBase /= 2; }

  double timePos = floor(leftTime() / (timeScaleBase*largeFreq)) * (timeScaleBase*largeFreq); //calc the first one just off the left of the screen
  int x, largeCounter=-1;
  double ratio = double(width()) / timeWidth();
  double lTime = leftTime();

  for(; timePos <= rightTime(); timePos += timeScaleBase) {
    if(++largeCounter == largeFreq) {
      largeCounter = 0;
      glColor4ub(25, 125, 170, 128); //draw the darker lines
    } else {
      glColor4ub(25, 125, 170, 64); //draw the lighter lines
	}
    x = toInt((timePos-lTime) * ratio);
    mygl_line(x, 0, x, height()-1);
  }
}
Example #11
0
int
main(int argc, char* argv[])
{
	int div;
	int max=0;
	int val = -1;

	for(div=1;div<1000;++div) {
		int i;
		int digits[1000];
		int ndigits;
		int num = 1;
		int nn = nmultiplier(div);
		memset(digits, 0, sizeof(digits));
		ndigits=0;

		for(i=0;i<1000;++i)
		{
			num *= pow10(nn);
		
			num %= div;

			if(!find(digits, ndigits, num))
				digits[ndigits++]=num;
		}
		if(ndigits>max)
		{
			max = ndigits;
			val=div;
		}
	}
	printf("%d\n", val);
	return 0;
}
Example #12
0
void TPercentageText::draw()
{
	ushort color = getColor(1);

	char *string = new char[size.x + 1];
	itoa( Round( percentage * pow10( precisionDigits ) ), string, 10 );

	if( precisionDigits > 0 )
		{
		memmove( &string[strlen( string ) - precisionDigits + 1],
			    &string[strlen( string ) - precisionDigits],
			    precisionDigits + 1 );
		string[strlen( string ) - 1 - precisionDigits] = point;
		}
	strcat( string, percentageString );
	if( string[0] == point )
		{
		memmove( &string[1], string, strlen( string ) + 1 );
		string[0] = '0';
		}

	TDrawBuffer b;
	b.moveChar( 0, ' ', color, size.x );
	b.moveStr( size.x - 1 - strlen( string ), string, color );
	writeLine( 0, 0, size.x, 1, b );

	delete[] string;
}
Example #13
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	double y;
	float d;
	int e, i, err = 0;
	struct d_d *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = pow10(p->x);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s pow10(%a)=%a, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperr(y, p->y, p->dy);
		if (!checkulp(d, p->r)) {
			printf("%s:%d: %s pow10(%a) want %a got %a ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
Example #14
0
/**
 * gwy_si_unit_get_format_with_digits:
 * @siunit: A SI unit.
 * @style: Unit format style.
 * @maximum: The maximum value to be represented.
 * @sdigits: The number of significant digits the value should have.
 * @format: A value format to set-up, may be %NULL, a new value format is
 *          allocated then.
 *
 * Finds a good format for representing a values with given number of
 * significant digits.
 *
 * The values should be then printed as value/@format->magnitude
 * [@format->units] with @format->precision decimal places.
 *
 * Returns: The value format.  If @format was %NULL, a newly allocated format
 *          is returned, otherwise (modified) @format itself is returned.
 **/
GwySIValueFormat*
gwy_si_unit_get_format_with_digits(GwySIUnit *siunit,
                                   GwySIUnitFormatStyle style,
                                   gdouble maximum,
                                   gint sdigits,
                                   GwySIValueFormat *format)
{
    const GwySIStyleSpec *spec;

    gwy_debug("");
    g_return_val_if_fail(GWY_IS_SI_UNIT(siunit), NULL);

    spec = gwy_si_unit_find_style_spec(style);
    if (!format)
        format = (GwySIValueFormat*)g_new0(GwySIValueFormat, 1);

    maximum = fabs(maximum);
    if (!maximum) {
        format->magnitude = 1;
        format->precision = sdigits;
    }
    else
        format->magnitude
            = gwy_math_humanize_numbers(maximum/pow10(sdigits),
                                        maximum, &format->precision);
    siunit->power10 = ROUND(log10(format->magnitude));
    format->units_gstring = gwy_si_unit_format(siunit, spec,
                                               format->units_gstring);
    format->units = format->units_gstring->str;

    return format;
}
Example #15
0
/*
 * The following prints a bitset with a 'ruler' that look like this
 *
 *              11111111112222222222333333333344444444445555555555666666666677
 *    012345678901234567890123456789012345678901234567890123456789012345678901
 * xx:........................................................................
 *                                11111111111111111111111111111111111111111111
 *    777777778888888888999999999900000000001111111111222222222233333333334444
 *    234567890123456789012345678901234567890123456789012345678901234567890123
 *    ........................................................................
 *    111111111111111111111111111111111111111111111111111111112222222222222222
 *    444444555555555566666666667777777777888888888899999999990000000000111111
 *    456789012345678901234567890123456789012345678901234567890123456789012345
 *    ........................................................................
 *    2222222222
 *    1111222222
 *    6789012345
 *    ..........
 *
 * to identify individual bits that are set.
 */
static void
bitset_print(bitset_t *bs, char *label, int width)
{
	int	val_start;
	int	val_max;
	int	label_width;
	int	ruler_width;
	int	v, vm, vi;
	int	nl, l;
	int	i;
	int	p;
	char	c;

	val_start = 0;
	val_max = bitset_highbit(bs) + 1;
	if (val_max <= val_start) {
		mdb_printf("%s: empty-set", label);
		return;
	}

	label_width = strlen(label) + 1;
	ruler_width = width - label_width;

	for (v = val_start; v < val_max; v = vm) {
		if ((v + ruler_width) < val_max)
			vm = v + ruler_width;
		else
			vm = val_max;

		nl = log10(vm) - 1;
		for (l = nl; l >= 0; l--) {
			p = pow10(l);
			for (i = 0; i < label_width; i++)
				mdb_printf(" ");

			for (vi = v; vi < vm; vi++) {
				c = '0' + ((vi / p) % 10);
				if ((l == nl) && (c == '0'))
					c = ' ';
				mdb_printf("%c", c);
			}

			mdb_printf("\n");
		}

		if (v == val_start) {
			mdb_printf("%s:", label);
		} else {
			for (i = 0; i < label_width; i++)
				mdb_printf(" ");
		}
		for (vi = v; vi < vm; vi++) {
			if (BT_TEST(bs->bs_set, vi))
				mdb_printf("X");
			else
				mdb_printf(".");
		}
		mdb_printf("\n");
	}
}
Example #16
0
static void
noise_synth_do(const NoiseSynthArgs *args,
               const GwyDimensionArgs *dimsargs,
               GwyDataField *dfield)
{
    const NoiseSynthGenerator *generator;
    PointNoiseFunc point_noise;
    GwyRandGenSet *rngset;
    gdouble *data;
    gdouble sigma;
    gint xres, yres, i;

    generator = get_point_noise_generator(args->distribution);
    point_noise = generator->point_noise[args->direction];

    rngset = gwy_rand_gen_set_new(1);
    gwy_rand_gen_set_init(rngset, args->seed);

    xres = gwy_data_field_get_xres(dfield);
    yres = gwy_data_field_get_yres(dfield);
    data = gwy_data_field_get_data(dfield);
    sigma = args->sigma * pow10(dimsargs->zpow10);

    for (i = 0; i < xres*yres; i++)
        data[i] += point_noise(rngset, sigma);

    gwy_rand_gen_set_free(rngset);
}
Example #17
0
static void
sigma_init_clicked(NoiseSynthControls *controls)
{
    gdouble mag = pow10(controls->dims->args->zpow10);
    gtk_adjustment_set_value(GTK_ADJUSTMENT(controls->sigma),
                             controls->zscale/mag);
}
void QuickAddCapacitorDialog::slotAttemptAutoComplete()
{
    QString text = ui->capacitanceValueLineEdit->text().trimmed();
    //We accept 3 digit value codes with an optional tolerance code
    if(text.length()==3 || text.length()==4){
        QString multiplicandStr = text.left(2);
        QChar multiplierChar = text.at(2);
        bool multiplicandOk;
        int multiplicand = multiplicandStr.toInt(&multiplicandOk);        
        if(multiplicandOk && multiplierChar.isDigit()){
            double capacitance = multiplicand * pow10(-12);
            int multiplierIdx = to_char(multiplierChar) - '0';
            if(multiplierIdx >= 0 && multiplierIdx <= 9){
                capacitance = capacitance * MULTIPLIERS[multiplierIdx];
            }
            QString capacitanceStr = UnitFormatter::format(capacitance, _capacitanceParam.unitSymbol());
            ui->capacitanceValueLineEdit->setText(capacitanceStr);
        }
        if(text.length()==4){
            QChar toleranceChar = text.at(3);
            if(toleranceChar.isLetter()){
                QString tolerance = lookupTolerance(to_char(toleranceChar));
                if(!tolerance.isEmpty()){
                    ui->toleranceLineEdit->setText(tolerance);
                }
            }
        }
    }

}
Example #19
0
File: csort.c Project: eposts/Rich
void get_number( int *a_number, int *times, char *tstring, int *x, int *y )
{
int power;         /* 十的指数,用10的power来乘以数字 */
char achar[2];
char bchar = 0;
achar[1] = 0;

while ( bchar <= 47 || bchar >= 59 )  /* 允许的数字0-9 */
  {
   bchar = getch();
   if ( bchar == 13 )   /* 13 = CR; 用户按了ENTER建  */
     {
      bchar = 48;
      *times = 0;
      break;
     }
  }

 if ( *times )
   {
    achar[0] = bchar;

    outtextxy( *x, *y, achar );
    *x = *x + textwidth( achar );
    tstring[TIMES - ( (*times)--)] = achar[0];
    if ( *times )
    get_number( a_number, times, tstring, x, y );
   }

    power = (int)( pow10(( strlen( tstring ) - ((*times) + 1))));
    bchar = tstring[*times];
    *a_number += ( power  * ( bchar - 48 ));
    (*times )++;
}
double round_up( double val, unsigned int dp )
{
    // Some implementations of std::pow does not return the accurate result even
    // for small powers of 10, so we use a specialized routine to calculate them.
    const double denominator = pow10( dp );
    return std::ceil( denominator * val ) / denominator;
}
Example #21
0
static TACommandVerdict pow10_cmd(TAThread thread,TAInputStream stream)
{
    double x, res;

    // Prepare

    x = readDouble(&stream);
    errno = 0;
    
    START_TARGET_OPERATION(thread);
    
    // Execute

    res = pow10(x);
    
    END_TARGET_OPERATION(thread);
    
    // Response
    
    writeDouble(thread, res);
    writeInt(thread, errno);

    sendResponse(thread);
    return taDefaultVerdict;
}
Example #22
0
File: charstod.c Project: 8l/cmm
double
charstod(int(*f)(void*), void *vp)
{
	double num, dem;
	int neg, eneg, dig, exp, c;

	num = 0;
	neg = 0;
	dig = 0;
	exp = 0;
	eneg = 0;

	c = (*f)(vp);
	while(c == ' ' || c == '\t')
		c = (*f)(vp);
	if(c == '-' || c == '+'){
		if(c == '-')
			neg = 1;
		c = (*f)(vp);
	}
	while(c >= '0' && c <= '9'){
		num = num*10 + c-'0';
		c = (*f)(vp);
	}
	if(c == '.')
		c = (*f)(vp);
	while(c >= '0' && c <= '9'){
		num = num*10 + c-'0';
		dig++;
		c = (*f)(vp);
	}
	if(c == 'e' || c == 'E'){
		c = (*f)(vp);
		if(c == '-' || c == '+'){
			if(c == '-'){
				dig = -dig;
				eneg = 1;
			}
			c = (*f)(vp);
		}
		while(c >= '0' && c <= '9'){
			exp = exp*10 + c-'0';
			c = (*f)(vp);
		}
	}
	exp -= dig;
	if(exp < 0){
		exp = -exp;
		eneg = !eneg;
	}
	dem = pow10(exp);
	if(eneg)
		num /= dem;
	else
		num *= dem;
	if(neg)
		return -num;
	return num;
}
Example #23
0
double
pow10(int n)
{
	int m;

	if(n < 0) {
		n = -n;
		if(n < sizeof(tab)/sizeof(tab[0]))
			return 1/tab[n];
		m = n/2;
		return 1/(pow10(m) * pow10(n-m));
	}
	if(n < sizeof(tab)/sizeof(tab[0]))
		return tab[n];
	m = n/2;
	return pow10(m) * pow10(n-m);
}
Example #24
0
static void
cnew_dialog_update(CNewControls *controls,
                        CNewArgs *args)
{
    gtk_adjustment_set_value(GTK_ADJUSTMENT(controls->xrange_from),
                             args->xrange_from/pow10(args->xyexponent));

}
Example #25
0
//---------------------------------------------------------------------------------------------------------------------//
boost::optional<float> OutField::getAsFloat(unsigned int precision) const
{
   if (!m_value)
   {
      return boost::none;
   }
   float const tmp = boost::lexical_cast<float>(boost::trim_left_copy_if(*m_value, boost::lambda::_1 == '0'));
   return boost::optional<float>(tmp / pow10(precision));
}
Example #26
0
long __Call_pow10( CDSR_VMEval& /*vm*/, MMD_Address& addr, UniWord *arg )
{
#if _DEBUG
	if( addr.param2 < 0 )
		throw _T("__Call_(fun) : internal error, out of range");
#endif
	*(arg - 1) = CDSRReal( pow10( (arg - 1)->getReal() ) );
	return 1 - addr.param3;
}
Example #27
0
void VibratoTimeAxis::setZoomFactorX(double x)
{
  zoomFactorX = 2*pow10(log2(x/25));

  // Do forced update on changed zoomwheel
  prevWindowOffset = -1;

  update();
}
Example #28
0
int AxisScale::getOptimalExponent(double low, double high)
{
	double range = high - low;
	int rangeExponent = floor(log10(range));
	
	int countU = (int) floor(fabs(range / pow10(rangeExponent)));

	return ((countU >= 3) ? rangeExponent : (rangeExponent - 1)); 
}
Example #29
0
File: 035.c Project: ilyak/euler
unsigned
rotate(unsigned n, unsigned len)
{
	unsigned last = n % 10;

	n /= 10;
	n += last * pow10(len - 1);

	return n;
}
Example #30
0
static void
xyuexponent_changed_cb(GtkWidget *combo,
                      CNewControls *controls)
{
    CNewArgs *args = controls->args;

    if (controls->in_update)
        return;

    controls->in_update = TRUE;
    args->xyuexponent = gwy_enum_combo_box_get_active(GTK_COMBO_BOX(combo));
    args->xunc = gtk_adjustment_get_value(GTK_ADJUSTMENT(controls->xunc))
                  * pow10(args->xyuexponent);
    args->yunc = gtk_adjustment_get_value(GTK_ADJUSTMENT(controls->yunc))
                  * pow10(args->xyuexponent);

    cnew_dialog_update(controls, args);
    controls->in_update = FALSE;
}