当前位置: 首页>>代码示例>>C++>>正文


C++ DBL2NUM函数代码示例

本文整理汇总了C++中DBL2NUM函数的典型用法代码示例。如果您正苦于以下问题:C++ DBL2NUM函数的具体用法?C++ DBL2NUM怎么用?C++ DBL2NUM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DBL2NUM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: stackprof_results

static VALUE
stackprof_results(VALUE self)
{
    VALUE results, frames;

    if (!_stackprof.frames || _stackprof.running)
	return Qnil;

    results = rb_hash_new();
    rb_hash_aset(results, sym_version, DBL2NUM(1.1));
    rb_hash_aset(results, sym_mode, _stackprof.mode);
    rb_hash_aset(results, sym_interval, _stackprof.interval);
    rb_hash_aset(results, sym_samples, SIZET2NUM(_stackprof.overall_samples));
    rb_hash_aset(results, sym_gc_samples, SIZET2NUM(_stackprof.during_gc));
    rb_hash_aset(results, sym_missed_samples, SIZET2NUM(_stackprof.overall_signals - _stackprof.overall_samples));

    frames = rb_hash_new();
    rb_hash_aset(results, sym_frames, frames);
    st_foreach(_stackprof.frames, frame_i, (st_data_t)frames);

    st_free_table(_stackprof.frames);
    _stackprof.frames = NULL;

    return results;
}
开发者ID:agrimm,项目名称:stackprof,代码行数:25,代码来源:stackprof.c

示例2: newsegment_parse

static VALUE
newsegment_parse(VALUE self)
{
    gboolean update;
    gdouble rate, applied_rate;
    GstFormat format;
    gint64 start, stop, position;

    gst_event_parse_new_segment_full(RGST_EVENT(self), &update, &rate,
                                     &applied_rate, &format, &start, &stop,
                                     &position);

    return rb_ary_new3(7, CBOOL2RVAL(update), DBL2NUM(update), DBL2NUM(rate),
                       GST_FORMAT2RVAL(format), LL2NUM(start), LL2NUM(stop),
                       LL2NUM(position));
}
开发者ID:Mazwak,项目名称:ruby-gnome2,代码行数:16,代码来源:rbgst-event.c

示例3: math_sqrt

VALUE
math_sqrt(VALUE obj, SEL sel, VALUE x)
{
    double d0, d;

    Need_Float(x);
    d0 = RFLOAT_VALUE(x);
    /* check for domain error */
    if (d0 < 0.0) {
	domain_error("sqrt");
    }
    if (d0 == 0.0) {
	return DBL2NUM(0.0);
    }
    d = sqrt(d0);
    return DBL2NUM(d);
}
开发者ID:Sophrinix,项目名称:MacRuby,代码行数:17,代码来源:math.c

示例4: math_atanh

static VALUE
math_atanh(VALUE obj, SEL sel, VALUE x)
{
    double d0, d;

    Need_Float(x);
    d0 = RFLOAT_VALUE(x);
    /* check for domain error */
    if (d0 <  -1.0 || +1.0 <  d0) {
	domain_error("atanh");
    }
    /* check for pole error */
    if (d0 == -1.0) return DBL2NUM(-INFINITY);
    if (d0 == +1.0) return DBL2NUM(+INFINITY);
    d = atanh(d0);
    return DBL2NUM(d);
}
开发者ID:Sophrinix,项目名称:MacRuby,代码行数:17,代码来源:math.c

示例5: rb_float_from_bson_double

/**
 * Convert the bytes for the double into a Ruby float.
 *
 * @example Convert the bytes to a float.
 *    rb_float_from_bson_double(class, bytes);
 *
 * @param [ Class ] The float class.
 * @param [ String ] The double bytes.
 *
 * @return [ Float ] The ruby float value.
 *
 * @since 2.0.0
 */
static VALUE rb_float_from_bson_double(VALUE self, VALUE value)
{
  const char * bytes;
  double v;
  bytes = RSTRING_PTR(value);
  memcpy(&v, bytes, RSTRING_LEN(value));
  return DBL2NUM(v);
}
开发者ID:trmmy,项目名称:bson-ruby,代码行数:21,代码来源:native.c

示例6: pq_second_best_key

/*
 * call-seq:
 *   second_best_key -> float
 *
 * Returns the priority of the second best element in the priority queue.
 */
static VALUE pq_second_best_key(VALUE self) {
   fc_pq::PQueue queue = pq_from_self(self);
   if(fc_pq::size(queue) < 2)
      return Qnil;
   
   double priority = fc_pq::second_best_key(queue);
   return DBL2NUM(priority);
}
开发者ID:boborbt,项目名称:priority_queue_cxx,代码行数:14,代码来源:FastContainers.cpp

示例7: length

static VALUE length(VALUE self)
{
  Leap::Pointable * pointer;

  Data_Get_Struct(self, Leap::Pointable, pointer);

  return DBL2NUM(pointer->length());
}
开发者ID:a3gis,项目名称:leap_motion,代码行数:8,代码来源:pointable.cpp

示例8: rb_rt_result

VALUE rb_rt_result(VALUE self) {
    rt_ctx *ctx;
    VALUE ret;

    Data_Get_Struct(self, rt_ctx, ctx);

    if(! ctx->ended)
        rt_end(ctx);

    ret = rb_hash_new();
    rb_hash_aset(ret, ID2SYM(rb_intern("entropy")), DBL2NUM(ctx->r_ent));
    rb_hash_aset(ret, ID2SYM(rb_intern("mean")), DBL2NUM(ctx->r_mean));
    rb_hash_aset(ret, ID2SYM(rb_intern("chisquare")), DBL2NUM(ctx->r_chisq));
    rb_hash_aset(ret, ID2SYM(rb_intern("montepi")), DBL2NUM(ctx->r_montepicalc));
    rb_hash_aset(ret, ID2SYM(rb_intern("scc")), DBL2NUM(ctx->r_scc));
    return ret;
}
开发者ID:wubugui,项目名称:ent,代码行数:17,代码来源:ent_native.c

示例9: pq_top_key

/*
 * call-seq:
 *   top_key -> float
 *
 * Returns the priority of the object at the top of the priority queue.
 */
static VALUE pq_top_key(VALUE self) {
  fc_pq::PQueue queue = pq_from_self(self);
  if(fc_pq::empty(queue))
    return Qnil;
  
  double priority = fc_pq::top_key(queue);
  return DBL2NUM(priority);
}
开发者ID:boborbt,项目名称:priority_queue_cxx,代码行数:14,代码来源:FastContainers.cpp

示例10: touch_distance

static VALUE touch_distance(VALUE self)
{
  Leap::Pointable * pointer;

  Data_Get_Struct(self, Leap::Pointable, pointer);

  return DBL2NUM(pointer->touchDistance());
}
开发者ID:a3gis,项目名称:leap_motion,代码行数:8,代码来源:pointable.cpp

示例11: math_lgamma

static VALUE
math_lgamma(VALUE obj, VALUE x)
{
    double d0, d;
    int sign=1;
    VALUE v;
    Need_Float(x);
    d0 = RFLOAT_VALUE(x);
    /* check for domain error */
    if (isinf(d0)) {
	if (signbit(d0)) domain_error("lgamma");
	return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1));
    }
    d = lgamma_r(d0, &sign);
    v = DBL2NUM(d);
    return rb_assoc_new(v, INT2FIX(sign));
}
开发者ID:senthilnayagam,项目名称:pure-math.rb,代码行数:17,代码来源:math.c

示例12: ltns_parse_float

int ltns_parse_float(const char* payload, size_t length, VALUE* out)
{
	char *end;
	double parsed_val = strtod(payload, &end);
	if (end != (payload + length) || *end != LTNS_FLOAT)
		return FALSE;
	*out = DBL2NUM(parsed_val);
	return TRUE;
}
开发者ID:l4u,项目名称:lazy_tnetstring,代码行数:9,代码来源:parse.c

示例13: strstat_timer_percentile

static VALUE strstat_timer_percentile(VALUE self, VALUE rb_percentile) {
  int percentile;

  percentile = NUM2INT(rb_percentile);
  if (percentile < 0 || percentile > 100)
    rb_raise(rb_eRuntimeError, "invalid percentile");

  return strstat_timer_query(self, DBL2NUM(percentile / 100.0));
}
开发者ID:kadwanev,项目名称:stream_stats,代码行数:9,代码来源:stream_stats.c

示例14: rb_rt_scc

VALUE rb_rt_scc(VALUE self) {
    rt_ctx *ctx;
    Data_Get_Struct(self, rt_ctx, ctx);

    if(ctx->ended)
        return DBL2NUM(ctx->r_scc);
    else
        return Qnil;
}
开发者ID:wubugui,项目名称:ent,代码行数:9,代码来源:ent_native.c

示例15: ph_current_input_on_current_change

void CCONV ph_current_input_on_current_change(PhidgetCurrentInputHandle phid, void *userPtr, double current) {
  ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
  while(sem_wait(&callback_data->handler_ready)!=0) {};
  callback_data->arg1 = DBL2NUM(current);
  callback_data->arg2 = Qnil;
  callback_data->arg3 = Qnil;
  callback_data->arg4 = Qnil;
  sem_post(&callback_data->callback_called);
}
开发者ID:csdehaan,项目名称:phidgets,代码行数:9,代码来源:phidgets_current_input.c


注:本文中的DBL2NUM函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。