Double to float (with some black magic)