By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

I was expecting a positive return value from Mod operation...

P: n/a
MLH
MyVariant = 24 mod 7.5

?MyVariant
0

Why does this return zero? I thought it
woudl be a number greater than zero.
Jul 19 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,
MyVariant = 24 mod 7.5

?MyVariant
0

Why does this return zero? I thought it
woudl be a number greater than zero.
7.5 is rounded up to 8 - as mod uses intergers only ( see help file)
so 24 / 8 = 0

Regards
Jens

Jul 19 '07 #2

P: n/a
Hi,
so 24 / 8 = 0
24 mod 8 = 0
;-)

Regards
Jens
Jul 19 '07 #3

P: n/a
In this case 7.5 was rounded up to 8 before the calculation.

8 goes evenly into 24 three times leaving no remainder (0).

If the example were 24 Mod 7.4, the 7.4 would be rounded Down to 7.
7 goes into 24 three times (7*3 = 21). 24 - 21 = 3

24 Mod 7.4 = 3

Warning - there are articles you may want to search for regarding how Access
handles rounding. In some cases .5 may be rounded either up or down
depending on the precision of the variable type you declare

Len
"MLH" <CR**@NorthState.netwrote in message
news:c2********************************@4ax.com...
MyVariant = 24 mod 7.5

?MyVariant
0

Why does this return zero? I thought it
woudl be a number greater than zero.

Jul 19 '07 #4

P: n/a
MLH
Thanks, guys. I see that now.
I've fallen back on my old friend, Int
to handle the job...

24 - (7.5 * Int(24/7.5)) gives me the 1.5 I was looking for.
Jul 20 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.