Hacker News new | past | comments | ask | show | jobs | submit login

Op is already in base 100 fixed point. I guess because that's what the sensor returns?

Though it might be smart to convert it to another format. Four nibbles of BCD would be ideal and the MCS-48 looks to have native support for it.

Thought you would need a custom version of shift by 4 that handles BCD.

Or simplify the equation to just adds:

    C2 = C + C
    C4 = C2 + C2
    C8 = C4 + C4
    C16 = C8 + C8
    Res = C16 + C2



If he's in base 100 and you multiply by 18 it's the same story: you are now in base 1000 and need a division to go back.

Converting from binary to BCD also needs division by constants, so again it's more or less the same.


Oh, right. I'm an idiot who forgot about the fixed point divide.

And yes, at some point you are going to need to do a divide by constant 10. It's unavoidable if you want a base 10 display. The option of using BCD to do calculations just lets you do that divide upfront, rather than at the end.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: