fix hashing of rationals (#9264)

Fixes #9264, also replace `x*2.0^y` by faster `ldexp(x,y)`.
Ahh, this might have been why: on 0.3.3:
```
julia> abs(int8(1)) |> typeof
Int64
```

Using 0.4-dev
```
julia> abs(int8(1)) |> typeof
Int8
```