Strange behaviour with MOD function

whytrigg

New Member
Joined
Jan 19, 2017
Messages
7
If anyone can help me understand what Excel is doing here, I would be very grateful.

I want to create a frequency chart basically using the % of something. I have a range of values between 0.00 and 1.00.

In an adjacent column I have the formula A1 - Mod(A1, 0.1)

for most of the results it behaves as expected, for example 0.71 returns the result 0.7, 0.8 returns the result 0.8 however, the value 0.6 returns the value of 0.5.

I have checked and there is no rounding in the target cell, the absolute value is "0.6".

Office support describes the mod function in line with my expectations " [FONT=&quot]MOD(n, d) = n - d*INT(n/d)"
[/FONT]

If I instead use the INT function as above I get the expected results.

Am I using the mod function incorrectly? what is it actually doing?

Thanks

David
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Re: Strange behaviour with MOD function - please help

If you multiply them all by 10 it works ok.
Same occurs with 2.6, 3.6, 4.6, 5.6

but not 1.6

0.600000000000001 produces 0.6
0.6000000000000001 produces 0.5
 
Last edited:
Upvote 0
Re: Strange behaviour with MOD function - please help

Interesting, thank you both.

I rely so much on excel, I had never considered the way it stores numbers could lead to precision errors when I was only using 1.d.p.

David
 
Upvote 0

Forum statistics

Threads
1,215,174
Messages
6,123,454
Members
449,100
Latest member
sktz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top