APIdock / Ruby
/
method

subsec

ruby latest stable - Class: Time
subsec()
public

Returns the fraction for time.

The return value can be a rational number.

t = Time .now  #=> 2009年03月26日 22:33:12 +0900
"%10.9f" % t.to_f  #=> "1238074392.940563917"
t.subsec  #=> (94056401/100000000)

The lowest digits of #to_f and #subsec are different because IEEE 754 double is not accurate enough to represent the rational number.

The more accurate value is returned by #subsec.

static VALUE
time_subsec(VALUE time)
{
 struct time_object *tobj;
 GetTimeval(time, tobj);
 return quov(w2v(wmod(tobj->timew, WINT2FIXWV(TIME_SCALE))), INT2FIX(TIME_SCALE));
}

AltStyle によって変換されたページ (->オリジナル) /