From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

剰余計算について

こんにちは。LABVIEW初心者のcsti22042です。ご質問失礼いたします。以下の問題を解いておりますが、正しく商と余りが表示されず、困惑しております。

 

X<0及びY>0の時、X/Yの商と剰余を計算する。

(i) |X|>Yの時

(ii)|X|<Yの時

 

(i)のパターンはうまく計算できますが、(ii)の時は商と剰余が正しい結果になりません。スクリーンショットを見ていただければわかると思いますが、ここでは商が0、余りが3になるはずです。

恐れ入りますが、ご教授いただければ幸いです。よろしくお願いいたします。

0 Kudos
Message 1 of 4
(803 Views)

-2/3 gives you Q=-1 and R=1, it is correct.


You are getting back X when you verify the results using,

X = Q*Y + R

 

R is always >=0 

 

Please refer to this article - https://people.ohio.edu/melkonia/math3050/HW/Section4.4.pdf

santo_13_1-1664387916134.png

 

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 4
(776 Views)

Thank you for your reply. Sorry for the late reply.

n div d = q and n mod d = r ⇔ n = dq + r

I understand the article about the formula above. I would like to create it in LabVIEW even if q is 0, but is it currently impossible?

0 Kudos
Message 3 of 4
(734 Views)

@csti22042 wrote:

Thank you for your reply. Sorry for the late reply.

n div d = q and n mod d = r ⇔ n = dq + r

I understand the article about the formula above. I would like to create it in LabVIEW even if q is 0, but is it currently impossible?


q=0 case is always possible and that is how LabVIEW also works. The important condition is that r>=0

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 4
(723 Views)