to_f()
public
Returns the result of interpreting leading characters in str as a
floating point number. Extraneous characters past the end of a valid number
are ignored. If there is not a valid number at the start of str,
0.0 is returned. This method never raises an exception.
"123.45e1".to_f
"45.67 degrees".to_f
"thx1138".to_f
Show source
/*
* call-seq:
* str.to_f => float
*
* Returns the result of interpreting leading characters in <i>str</i> as a
* floating point number. Extraneous characters past the end of a valid number
* are ignored. If there is not a valid number at the start of <i>str</i>,
* <code>0.0</code> is returned. This method never raises an exception.
*
* "123.45e1".to_f
* "45.67 degrees".to_f
* "thx1138".to_f
*/
static VALUE
rb_str_to_f(str)
VALUE str;
{
return rb_float_new(rb_str_to_dbl(str, Qfalse));
}