The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Rmod not working as it should?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
andrewdsto Posted - 07/16/2015 : 03:15:28 AM
Origin Ver. 2015 and Service Release sr2 (Select Help-->About Origin):
Operating System:Windows 7

Hi,
Just a short question on the rmod function. I dont think it is working as it should, see below.

rmod(6,2)=;
returns
rmod(6,2)=0

All ok, same the mod function. now

5*4.2=;
rmod(21,4.2)=;

we get

5*4.2=21
rmod(21,4.2)=4.2

however

rmod(21,5)=;
returns
rmod(21,5)=1

again ok
and

rmod(21,4.1)=;
returns
rmod(21,4.1)=0.5

again ok

its only when the remainder is meant to be zero we instead get the divisor.

interestingly if we run the folowing
4.2*6=;
25.2-(6*4.2)=;

we get
4.2*6=25.2
25.2-(6*4.2)=-3.5527136788005E-15

that is we do not get zero but instead a very small number.

I am thinking that where the modulus is zero, the rmod funtion infact returns not zero but a number that is very close to, but just below, the divisor which gets returned as the divisor. But this is only for real numbers and not integers.

just a thought.

thanks
Andrew
1   L A T E S T    R E P L I E S    (Newest First)
SeanMao Posted - 07/16/2015 : 04:41:31 AM
Hi,

This is due to the rounding error, when you do rmod(21,4.2) you actually get remainder 4.199999... rather precise 0.

Regards!

Sean

OriginLab Tech. Service

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000