This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-IQMATHLIB: Bug in _atoQ() for negative strings without a decimal point

Part Number: MSP-IQMATHLIB

Similar to the issues here: http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/348830/1830267#1830267

If I pass a negative string to _atoQ() the polarity of the result depends on if there is a decimal point included.

E.g. the follow example demonstrates this issue:

_q8 expected = _Q8(-50.0);
_q8 without  = _atoQ8("-50");
_q8 with     = _atoQ8("-50.");
   
printf("Expected: 0x%x (%d)\n", expected, _Q8int(expected));
printf("Without : 0x%x (%d)\n", without, _Q8int(without));
printf("With    : 0x%x (%d)\n", with, _Q8int(with));

/*
PRINTS:
Expected: 0xce00 (-50)
Without : 0x3200 (50)
With    : 0xce00 (-50)

ALL results should be -50. */

Obviously this is not too tricky to workaround, but it is definitely a bug that should be addressed by the library.

Additionally, is there any place where we can find the state of open bugs against libraries like this? As I find that is often a good to review open bug lists before posting something like this.

  • Hello,

    Andrew Dodd1 said:

    First, thanks for searching the forum and finding this related thread. It helps frame the context especially if there was previous discussion about a similar topic.

    Andrew Dodd1 said:

    If I pass a negative string to _atoQ() the polarity of the result depends on if there is a decimal point included.

    E.g. the follow example demonstrates this issue:

    Also, thanks for sharing the code. I could quickly and easily replicate it on my side.

    Andrew Dodd1 said:
    Obviously this is not too tricky to workaround, but it is definitely a bug that should be addressed by the library.

    Agreed. I would recommend not using the string functionality but instead use the _Q8 function instead.

    Andrew Dodd1 said:
    Additionally, is there any place where we can find the state of open bugs against libraries like this? As I find that is often a good to review open bug lists before posting something like this.

    Unfortunately, our list of bugs is not publicly accessible. However, what you did by searching the forum before posting is excellent. Internally, I was able to find the bug mentioned in the thread linked above. It appears that the initial issue was resolved but the follow-up issue was not. I'll update the bug, so that it gets resolved in a later release. Thanks for making us aware of it!

    Regards,

    James

  • Hi James,

    Unfortunately I cannot use the float-casting macros, as the value I have is a string (i.e. it is coming from a Command Line Interface). I guess I could convert to a float/double and then convert to a Q number....but that sort of misses the point.

    I'm glad I could highlight it for you. It is a real shame that the bug tracking etc isn't available, as it would definitely help.

    Anyway, keep up the good stuff TI, it's great the libraries you publish. Hopefully this one gets a new release soon,
    Thanks,
    Andrew
  • Hello,

    That makes sense. Perhaps your code could check if the string from the terminal includes a decimal, and if not, append one at the end before passing it into the Q function. Thanks for your feedback too. I'll pass it along.

    Regards,

    James

**Attention** This is a public forum