Note to @Gordon would you briefly describe how the floating point section works to build it's values please, and maybe where in the source they are extracted. Are log tables used? More of a curiosity question as I hadn't realized how complex doing 'simple' math actually is for a micro.
If you provide a link to a datasheet, description and the original source, we may be able to figure out what it wants to do, and help with a re-implementation.
A re-implementation from the original C line
uint64_t frf = ((uint64_t)val << 19) / 32000000;
can be re-written to C code using floating point numbers
uint64_t frf = (uint64_t)((float)val * 0.016384);
var frf = Math.round(val * 0.016384);
(0.016384 is equal to Math.pow(2, 19) / 32000000)
© Espruino, powered by microcosm.
Report a problem