Modulus

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I have this problem.
I normal mathematics.
z=x/y

If i want to calculate x and i know z and y.
Then i can use x= z*y.

now z=x%y

i know z.i want to calculate x. How do i do this??

I do not know if this is even possible. If now what other formula can
i use.
 
I have this problem.
IN normal mathematics.
z=x/y

If i want to calculate x and i know z and y.
Then i can use x= z*y.

now z=x%y

i know z.i want to calculate x. How do i do this??

I do not know if this is even possible. If NOT what other formula can
i use.

There are some spelling mistakes. Corrected as above
 
I have this problem.
IN normal mathematics.
z=x/y

If i want to calculate x and i know z and y.
Then i can use x= z*y.

now z=x%y

i know z.i want to calculate x. How do i do this??

I do not know if this is even possible. If NOT what other formula can
i use.

One of two things:

A) You meant to say "I know z AND Y."

B) You really don't know y. In this case, it's impossible because you still
have two variables.

Please clarify which case is true.
 
One of two things:

A) You meant to say "I know z AND Y."

B) You really don't know y. In this case, it's impossible because you still
have two variables.

Please clarify which case is true.

Sorry, you are right. I meant i know z and y.
 
Bob said:
Sorry, you are right. I meant i know z and y.

The solutions are:

x = z + n * y; where n represent every integer value

So, mathematically there is an infinite number of solutions. Practically
it's limited by the range of the variable type you are using for the
variables. For Int32 variables and an y value of 1000 there are 4294967
solutions.

Example, we go from one of the solutions:

x = 15, y = 10; z = 15 % 10; z = 5

the solutions are:

x = z + n * y; x = 5 + n * 10

for n = 1; x = 5 + 1 * 10; x = 15
 
The solutions are:

x = z + n * y; where n represent every integer value

So, mathematically there is an infinite number of solutions. Practically
it's limited by the range of the variable type you are using for the
variables. For Int32 variables and an y value of 1000 there are 4294967
solutions.

Example, we go from one of the solutions:

x = 15, y = 10; z = 15 % 10; z = 5

the solutions are:

x = z + n * y; x = 5 + n * 10

for n = 1; x = 5 + 1 * 10; x = 15

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Thanks Göran,

I understand the basics now.

What i am trying to do is the following.

I have to go to through a series of values and produce a chart between
littres and gallons. (1 gallon = 4.546 litres).

litres gallons
1.000 0.220
2.000 0.440
2.273 0.500
3.000 0.660
4.000 0.880
4.546 1.000
5.000 1.100

I am calculating the gallons from the litres. But when i have 0.50
gallons, i calculate the litres and also for 1 gallon and 1.5 gallons
and so on.

I think that to accomplish that i have to use the formula you wrote in
combination with the if loop.

It is an assignment i have to do. I do not excpect to get the answer
on a platter. But please give me a push in the right direction.

Thanks
 
Bob said:
I understand the basics now.

What i am trying to do is the following.

I have to go to through a series of values and produce a chart between
littres and gallons. (1 gallon = 4.546 litres).

litres gallons
1.000 0.220
2.000 0.440
2.273 0.500
3.000 0.660
4.000 0.880
4.546 1.000
5.000 1.100

I am calculating the gallons from the litres. But when i have 0.50
gallons, i calculate the litres and also for 1 gallon and 1.5 gallons
and so on.

I think that to accomplish that i have to use the formula you wrote in
combination with the if loop.

It is an assignment i have to do. I do not excpect to get the answer
on a platter. But please give me a push in the right direction.

But this has absolutely nothing to do with the question you originally
asked.

Are you trying to create a chart showing liters vs gallons for liter values
that are integers, and gallons that are a multiple of 0.5, and display them
in increasing order? If I were doing that, I would keep two variables like
this:
fromLiters = 1.0;
fromGallons = 0.5;

Then, in a loop, I'd figure out which one was smallest (remembering to
convert one first!), convert it, print it, and bump it to the next value.
 
Tim said:
But this has absolutely nothing to do with the question you originally
asked.

That's my reacton too...
Are you trying to create a chart showing liters vs gallons for liter values
that are integers, and gallons that are a multiple of 0.5, and display them
in increasing order? If I were doing that, I would keep two variables like
this:
fromLiters = 1.0;
fromGallons = 0.5;

Then, in a loop, I'd figure out which one was smallest (remembering to
convert one first!), convert it, print it, and bump it to the next value.

Or even simpler, as you know that one is more frequent you can just loop
through one of them and keep a variable for the other one. :)
 
That's my reacton too...



Or even simpler, as you know that one is more frequent you can just loop
through one of them and keep a variable for the other one. :)

Thanks. This was great help. Didn't know it was that simpel.
Thanks for your help again. Couldn't do it on my own.
 
Modulo is a one-way operation. That's how RSA encryption works, so no, it's
not possible.
 
Back
Top