IEEE compliant math (no unsafe)

Signed-off-by: Alec Ari <neotheuser@ymail.com>