You are reading a single comment by @Robin and its replies.
Click here to read the full conversation.
-
Sun 2019.07.28
'I'm too lazy to test the result in JavaScript'
@AkosLukacs perfomed the how proof in #3 and #4
I explained the why in #19
'For me it doesn't look like there's any need to shift ones and zeros'
There isn't any bit masking in that example. It is a division proof using type casting in C.
Will work on the I2C slave example you posted:
Thank you for that suggestion
While
((uint64_t)val << 19) / 32000000
does no rounding, but you still have some loss in accuracy unless the number is an integer multiple of "32000000". The final result has only three bytes, as needed for the next steps.I'm too lazy to test the result in JavaScript using a 64 bit math module vs. normal numbers, but in C it is like this:
If you want to see more than "Hello World", "Done" change
b = (__uint64_t)((double)i * 0.016384);
tob = (__uint64_t)((float)i * 0.016384);
.For me it doesn't look like there's any need to shift ones and zeros. Think about it.
@AkosLukacs:
The source is most likely this file here, found by searching for "<< 19) / 32000000".
For the linked code: A 32 bit frequency value is taken as input, converted to 24 bit (three byte values) with a loss in accuracy of 8 bit.