Jump to content

Quotient & Remainder function w/ negative inputs


Recommended Posts

OK, I'm willing to admit extreme ignorance as to how one of the most basic functions in the programming world is supposed to work, but I'm a little confused at the output of the "Quotient & Remainder" function in LabVIEW 7.1.1.

My assumption is that this function should compute and return the quotient and remainder of its two inputs, regardless of their sign. Therefore if the inputs are 100 and 90, I would expect a quotient of 1 and a remainder of 10. Similarly, if the inputs were -100 and 90, I would expect a quotient of -1 and a remainder of -10. However, for this latter case, this is not what you get (see attachment).

...So what am I missing?

post-1561-1125410988.jpg?width=400

Link to comment

Well, as usually happens once you make a post, I figured it out. First of all, just what the correct answer should be varies from programming language to programming language (hence my confusion), and there is much debate on the topic among mathematicians (http://mathforum.org/library/drmath/view/52343.html). However, the key here is the "floor" function (at the output of the Q & R function), which helps to explain what LabVIEW behaves as it does.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.