-1

What I mean is, let's say that I have number between 0 - 400. If I were to pass in 0, it would return 400, if I were to pass in 1 it would return 399, and so on and so forth. Is there an equation that will let me do this? (Yes, I know this isn't really java as much as it is plain Math)

EDIT: WOW, I'm and idiot. How did I NOT realize that this was subtraction? My problem is with Slick2D, and I'm having difficulty working with the LWJGL origin (0, 0 being in the top left) v.s. the other origin (0, 0 being in the bottom left)

EDIT 2: Requesting for a moderator to delete this

4

3 回答 3

6

这叫做减法

你拿最高的号码,打电话给它N。取下限,叫它M。然后你把原来的号码,打电话给它i。然后

答案 = (N - i) + M;

于 2012-04-21T01:45:56.543 回答
2

I think you're looking for the difference.

f(n) = 400 - n

In Java, this might look like:

int getOpposite(int n) {
    return 400 - n;
}

For even numbers, passing in n/2 will return n/2 -- so in the case of 400, passing in 200 will just return 200.

于 2012-04-21T01:45:39.543 回答
1

n = ULimit - n ; 会给你相反的

于 2012-04-21T01:46:38.383 回答