Use `as_int(numerator)`

And, probably, you want to use more short names for local variables.  For example, just `n`.