make the reference code use double instead of float where it is easy