本文整理汇总了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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例7: length
static VALUE length(VALUE self)
{
Leap::Pointable * pointer;
Data_Get_Struct(self, Leap::Pointable, pointer);
return DBL2NUM(pointer->length());
}
示例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;
}
示例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);
}
示例10: touch_distance
static VALUE touch_distance(VALUE self)
{
Leap::Pointable * pointer;
Data_Get_Struct(self, Leap::Pointable, pointer);
return DBL2NUM(pointer->touchDistance());
}
示例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));
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}