View Single Post
  #7   Spotlight this post!  
Unread 01-02-2013, 18:16
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: remainder function

Quote:
Originally Posted by 1075guy View Post
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
Attached Thumbnails
Click image for larger version

Name:	Java_IEEEremainder.png
Views:	18
Size:	6.2 KB
ID:	13749  Click image for larger version

Name:	20.11.14.png
Views:	18
Size:	9.8 KB
ID:	13750  
Reply With Quote