-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add special handling of 0 bit integer parts #19
Comments
I would like to implement my robot's navigation using fixed point arithmetic. For navigation I need to have the sine/cosine functions which both return pure fractional values and can be computed using pure fractional arithmetic. Thus being able to use SFixed<0,15> values and arithmetic is very important to me. |
@dackley1935 Does it have to be |
Thanks for the quick reply. SFixed<1,14> looses one bit of accuracy versus SFixed<0,15> which is important for accurate navigation and I'd rather not have to go to SFixed<1,15> for performance reasons. |
Ok, I will try to prioritise this issue given that there is now a tangible need for it. Just to check, are you aware that without an integer bit you won't be able to achieve values of |
Hello again. I believe that without an integer bit one is able to represent -32768/32768 to 32767/32768 which is -1.000000000 to 0.999969482421875 and as you say, this gives steps (resolution) of 1/32768 where as with one integer bit the steps (resolution) is only 1/16384. |
I think you might be right about the -1.0 thing. As for 'BAMS', I have encountered it before under the name 'brads' ('binary radians', and in fact, the code I linked to earlier used 1-byte brads as the angle of measurement). Like I say, I'll prioritise this issue given that there is a tangible use-case. |
I have started work on this issue, the changes so far can currently be found on this branch: https://github.com/Pharap/FixedPointsArduino/tree/add-0-integer-part-specialisation I don't currently have much time for working on it, but I've got it to a point where it compiles and runs. |
At the moment:
0
as an integer part forUFixed
results in warnings0
as an integer part forSFixed
results in errorsThus the cases of 0 bit integer parts should be handled specially,
through template specialisation, a new type or through some other means.
The text was updated successfully, but these errors were encountered: