I remember in java that, the modulo operator could be inverted so that rather than seeing what the remainder is of an operation, you could invert it, so instead it will tell you many times a number was divided by:

```
Console.WriteLine(1000 % 90);
Console.WriteLine(100 % 90);
Console.WriteLine(81 % 80);
Console.WriteLine(1 % 1);
```

**Output:**

- 10
- 10
- 1
- 0

*Examples courtesy of DotNetPerls*

Rather than seeing the remainder, I want to see how many times '80' went into '81'. Which should be 1 with a remainder of 1.

Does the c# modulo operator support this behaviour? If not, how might achieve the desired behaviour? With minimal code please ... :D

EDIT:

I imagine the answer is going to be something simple like dividing the two numbers and getting rid of the '-.#' value and keeping the integer '1.-'. I know about this but there must be a slicker way of doing this?

What you are looking for is called *integer division*. It is not related to the modulo operator at all.

To perform an integer division, simply ensure that neither operand is a float/double.

Example:

```
int one = 81 / 80;
```

This gives you `1`

while `double notOne = 81.0 / 80`

would give you `1.0125`

for example.

You already got the answer, no need to deal with the decimals if you assign it to an integer.

In your comment you say that you are working with decimals, then Math.Floor is a possibility. ie:

```
double d = Math.Floor(81.0 / 80.0); // 1.0000....
```

```
Console.WriteLine(1000 % 90); // modulo = 10
Console.WriteLine(1000 / 90); // integer division = 11
Console.WriteLine(1000 / 90.0); // floating point division = 11.1111111111111
```

So I kinda get your question even though everyone else is on your case about it. In order to balance integer division you need to have the modulo operator in order to handle the remainder: `((1000 / 90) * 90) + (1000 % 90) == 1000`

.

Luckily you're asking a different question from what an inverse of a modulo would be. An inverse of a modulo would theoretically be able to give you an unknown numerator or divisor.

For instance, say you have `n % d = r`

. You know r and d, and n is unknown. The modulo function is expressed as `n % d = n - d*INT(n/d)`

. So `r = n - d*INT(n/d)`

. I can't think of how this can be directly solved, since you would need to know INT(n/d) when you don't know n.

Similar Questions

I've written the code for multiplicative inverse of modulo m. It works for most of the initial cases but not for some. The code is below: (define (inverse x m) (let loop ((x (modulo x m)) (a 1)) (cond

Possible Duplicate: Opposite of %in% What is the opposite of matrix[matrix%in%1,]? !%in% does not work. I would like to select items that do not contain a certain number.

I'm writing some code for a very limited system where the mod operator is very slow. In my code a modulo needs to be used about 180 times per second and I figured that removing it as much as possible

What does Scala's @ operator do? For example, in the blog post Formal Language Processing in Scala, Part 2 there is a something like this case x @ Some(Nil) => x

Why does this code give me an answer of 25? public int findGcd() { int num = this.num; int den = this.den; while (den != 0) { int t = den; den = num % den; num = t; } return num; } This is the main m

Is there a function is MySQL that automatically UPDATEs the value to the opposite one (something like ! NOT operator in php), without fetching the data, changing the value and inserting it again. Also

Here is my code so far: public class Token { // Data: private String type = ; private String name = ; private double value = 0; // Constructors: public Token() { this( ); } public Token( String

In the CoffeeScript documentation on operators it says that you can use %% for true mathematical modulo, but there is no explanation as to why this is different from the modulo operator % in JavaScr

This question already has an answer here: Javascript modulo not behaving 9 answers In JavaScript the % operator seems to behave in a very weird manner. I tried the following: >>> (0 -

Please check below fiddle link, Is there any way to achieve opposite direction curve (invert), js fiddle link .roundCorner { width: 170px; height: 20px; padding: 2em; border: 1px solid; border-radius:

I have a simple question, I've the following lines which equals to not active links: $links.not($active).each(function() { //Do sth... }); what is the opposite of the .not(...) function in JavaScript

There's something I don't understand about how the assignment operator works, please have a look at this piece of code: #include <iostream> using namespace std; class foo { int val{}; public: fo

rails new creates a new Rails application, the entire Rails directory structure. But is there an opposite operation of rails new? The command that would delete what the rails new created. Or may I hav

i wanted to make my own quarter-final draw for the champion's league (tomorrow, friday 16 of march) : i've got 2 questions : first the modulo does not work : it shows another match after every entry

I was just wondering what is the opposite of static? Im looking for a word or terminology to describe it. eg: #region Members #region Static private static Settings _Instance = null; #endregion Static

Why modulo runs fine with decimal but not with float/real MSDN states about it must be a valid expression of any one of the data types in the integer and monetary data type categories, or the numeric

HELP! I'm trying to create a hash table using Separate Chaining. For some unknown reason I cant seem to traverse and find all the original int I loaded. I suspect the modulo function is giving me bad

I want to get the opposite number of binary number (means x--> -(x) and -(x) --> x). What will be the algorithm ? I thought about change all bits (1 to 0 and 0 to 1) and add 1 to it. I

Let A be an matrix of size [n,n]. If I want to extract its diagonal, I do diag(A). Actually, I want the opposite diagonal, which would be [A(n,1),A(n-1,2),A(n-2,3),...]. One way to do this is via dia

Does there exist an opposite tag to <strong> in HTML? Or will it be introduced in HTML5?

I'm trying to set a variable with the results of a modulo, but seems my syntax isn't acceptable by Windows 7 batch. Demonstration code: @echo off for /L %%i in (1,1,8) do ( echo.i %%i set /a mod=%%i

I wonder if there is some method to get correct remainder of N after dividing with Q (or modulo Q) from the given remainder of N after dividing with P(or modulo P). In other words you have N%P, P and

Why is overloaded operator= mandated to be a member function ($13.5.3), but not a compound assignment operator e.g. operator+= ($13.5.2)? Am I overlooking something here?

I need to create an algorithm implemented in C that do modulo arithmetic between an arbitrary number of bytes and one byte. See this: typedef struct{ u_int8_t * data; u_int16_t length; }UBigInt; u_int

I'm trying to work out how the modulo operation 1 % 32 is equal to 1, and 2 % 32 is equal to 2, and so on and so forth. I have this code: uint8_t value; for (uint16_t i = 0; i < 64; i++) { value =

How do I find the modulo (%) of two long values in Java? My code says 'Integer number too large' followed by the number I'm trying to mod. I tried casting it to a long but it didn't work. Do I have to

Hello I need Opposite for this regex to use wih notepad+++ \d{2}-\d{2}|\d{2,4}[+-] Now It's replace years ML 12+ (W166) = ML (W166) FREELANDER II 07+ = FREELANDER II Kuga 08-12 = Kuga CRV 2012+ = CRV

Why would you need to overload the [] operator? I have never come across a practical scenario where this was necessary. Can somebody tell me a practical use case for this.

I'm curious as to whether Mustache has a syntax feature that is the opposite of the Inverted Selection syntax {{^foo}}. Let's say we have the data: { people: [ { name: Alice }, { name: Bob }, {

I am using OpenCV library. It doesn't have a modulo operator that can be applied to WHOLE matrix. It has a Multiplication, Subtraction operators for a matrix. Is there any way I can combine these oper

As you can see in the image below then when the browser window is resized the checkbox labels can wrap to the opposite side of their ascociated checkboxes. In the image above the label for checkbox 12

I am trying to write the script where i am searching a keyword . As soon as i am getting that keyword i have to backtrack the file i mean i have to start reading the file in opposite direction until i

Is there a method that does the opposite of the Environment.ExpandEnvironmentVariables method. What I mean, is that upon given a path, the method returns its EnvironmentValue counterpart. For example:

This question already has an answer here: Javascript modulo not behaving 9 answers I type this into google/wolfram alpha: -15 % 360 and I get 345. when I do it in javascript I get -15 https://w

In the Core Java Volume1 book there is a caution that say: CAUTION: The right-hand side argument of the shift operators is reduced modulo 32 (unless the left-hand side is a long, in which case the r

I have few question about () operator. Please help me to get clear idea. What is the use of () operator (() operator overloading). In which situations it should use. What are the practical example of

I was wondering how Javascript handles modulo. For example, what would Javascript evaluate 47 % 8? Thanks. I can't seem to find any documentation on it, and my skills on modulo aren't the best... Than

I a trying to dynamically add rows and populate them with 3 col-sm-4 using a modulo against the number of objects in a returned object from a function. Code: function formatSeriesCard(series) { var c

How can i do modulo arithmetic with decimal value since PHP only can do modulo with integer? Example case: echo 1.92 % 1000; // (int) 1, expected result should be 1.92 is there any library to do thi

I did this example to understand the use of [] operator but this code is giving me an error declaration of operator as array of function, no match for operator[] in Example[0] and same different e

What are the basic rules and idioms for operator overloading in C++? Note: The answers were given in a specific order, but since many users sort answers according to votes, rather than the time they w

I wrote a program to calculate Fibonacci numbers, and it works fine. Then I altered the program to give me the Fibonacci numbers modulo 65536, and all my output became zeros. What went wrong? import t

Is it possible to overload addition operator(+) for the addition of arrays? Something like: double operator+ (double a[], double b[]) { double c[]; c[] = a[] + b[]; return c; }

Here is my operator definition in my class : T& operator*(){ return this->element_; } When I use it like that, it is called : std::cout << n->operator*() << std::endl; It does

Let's say I have this: struct coor { int x; int y; COORD operator=(coor c) { COORD C={c.x,c.y} return C; } } and I needed to do: coor c={0,0}; COORD C=c; I could add operator overloading to coor, bu

Is there a way to do the opposite of String.Split in .Net? That is, to combine all the elements of an array with a given separator. Taking [a, b, c] and giving a b c (with a separator of ).

A derives directly from Object class and neither A or Object overload == operator, so why doesn't next code cause an error: class Program { static void Main(string[] args) { A a1 = new A(); A a2 = new

As the title asks. Are they opposite? Also how can I remove an event from the $rootScope based on its name? A simple example would be also welcome.

after SELECT information from server, i'm Getting Date Formate as YYYY / MM / DD. i'm trying opposite the date to DD / MM / YYYY the information must to be echo in JSON array. can you help me opposit

I'm looking for a way to create a 3D grid based on two opposite endpoints (a=(x1,y1,z1) and b=(x2,y2,z2)) of the cube. The step size is 1 in each dimension. Just found some numpy fcts that start with