Method: DataView#set_float64
- Defined in:
- ext/type_array/data_view.c
#set_float64(2, 77.643) ⇒ nil
Sets a float64 value at a given offset, using the provided endianness.
Examples
buf = ArrayBuffer.new(100) => ArrayBuffer
view = DataView.new(buf) => DataView
view.set_float64(2, 77.643) => nil
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'ext/type_array/data_view.c', line 489
static VALUE rb_data_view_set_float64(int argc, VALUE *argv, VALUE obj)
{
double val;
DataViewAset(obj);
switch (TYPE(item)) {
case T_FIXNUM:
val = (double)FIX2LONG(item);
break;
case T_BIGNUM:
val = rb_big2dbl(item);
break;
case T_FLOAT:
val = RFLOAT_VALUE(item);
break;
default:
rb_raise(rb_eTypeError, "Type arrays only support Fixnum, Bignum and Float instances");
}
rb_type_array_set_float64(buf->buf, index, val, little_endian);
return Qnil;
}
|