# Mod Q

#### Hap

##### Well-known Member
I would like to use a function like the "Mod" operator. My problem with the Mod operator is that it rounds floating point numbers to integer before returning a value. I am hoping there is another function that I can use that will return the remainder of the division of two floating point numbers.

Any guidance would be appreciated.

### 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.
Could you give an example please?

There shouldn't really be a remainder when you divide 2 floating point numbers.

eg

1.2/0.5=2.4

What would you say the remainder was there?

Do you mean the decimal part?

Can you give an example of where the MOD function doesn't return what you'd like?

The mod function returns the remainder of the division of two integers. If you equate a result to Integer Mod 1 the result is 0 because the all integers are divisible by one but if you equate a result to 19 Mod 2 you will get a result of 1.

I would like to be able to equate 3.14159 Mod 3 and get .14159 or 3.14159 Mod .1 and get .04159.

Hopefully that is a little clearer than mud!

Thanks

Hap said:
The mod function returns the remainder of the division of two integers. If you equate a result to Integer Mod 1 the result is 0 because the all integers are divisible by one but if you equate a result to 19 Mod 2 you will get a result of 1.

I would like to be able to equate 3.14159 Mod 3 and get .14159 or 3.14159 Mod .1 and get .04159.

Hopefully that is a little clearer than mud!

Thanks

Still mud I guess...

Maybe you're looking for:

=A2-TRUNC(A2)

That is the right idea. I am trying to code it.

Example

If 1.2345 / .25 = 4.938

Then .25 goes into 1.2345 only 4 times so the remainder
will be .938 * .25

I hope the puddle is getting clearer.

Hap said:
That is the right idea. I am trying to code it.

Example

If 1.2345 / .25 = 4.938

Then .25 goes into 1.2345 only 4 times so the remainder
will be .938 * .25

I hope the puddle is getting clearer.

What is the desired result: 0.938 or 0.938*0.25?

.938*.25

I just finished my own Mod Function to do what I want. Maybe there is already something like this out there.

Public Function Mod2(X As Double, Y As Double)

Dim Z As Double
Dim Z2 As Double

Z = X / Y
Z2 = WorksheetFunction.Floor(Z, 1)
Z = Z - Z2
Z = Z * Y

Mod2 = Z

End Function

=((A1/B1)-INT(A1/B1))*B1

Replies
4
Views
179
Replies
5
Views
322
Replies
5
Views
420
Replies
5
Views
189
Replies
0
Views
178

1,221,522
Messages
6,160,308
Members
451,637
Latest member
hvp2262

### 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.

### Which adblocker are you using?

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

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