2 ms·
The C code for Fixnum#to_f is quite literally fix_to_f(VALUE num) { double val; val = (double)FIX2LONG(num); //RSHIFTs sign return DBL2NUM(val);
by ROFISH 18y ago
The C code for Fixnum#to_f is quite literally
fix_to_f(VALUE num) {
double val;
val = (double)FIX2LONG(num); //RSHIFTs sign
return DBL2NUM(val); //Ruby float constructor of C double value
}
It does the same thing. Ruby, by design, flows left to right instead of nested params. This way you don't have float(user.timestamp) but instead user.timestamp.to_f.