Quote:
Originally Posted by 1075guy
If you have a function that works, then use it?
|
I do use it. But I don't want to be telling other people to use my custom function if there's already a perfectly good remainder function provided with FRC C++. I don't have access to a working C++ installation, otherwise I would test it myself. I am seeking help from knowledgeable C++ users on this forum.
Quote:
|
I don't understand your qualm?
|
Honestly, that's because I don't have a qualm. I am perfectly calm.
Quote:
|
I have not ever encountered a programming scenario where modulus division didn't solve my desire for a remainder, so I'm a bit lost.
|
I have encounted at least one such scenario, and that's why I posted this thread.
For example, the IEC60559 remainder function can take any angle and normalize it to the range -180..+180 with a single C instruction:
normalizedAngle = remainder(angle,360);
I'd like to know if the remainder function is supported in FRC C++ so I can recommend it to students who are trying to do this type of conversion.
Neither the fmod() function nor the % operator can replicate the functionality of the remainder() function without using a bunch of conditional logic
If there are any Java programmers following this thread, Java appears to have the IEC 60559 remainder function; in Java it is called
IEEERemainder. See attachments. If someone would be willing to test that (compare it to the implementation I posted ealier in this thread) I'd be grateful.
qualm
/kwä(l)m/
Noun
1) An uneasy feeling of doubt, worry, or fear; a misgiving.
2) A momentary faint or sick feeling.
Synonyms
nausea - queasiness