a bunch more work on C implementation and converting between float and int correctly