我有4个零3个,是一个大体(目标),我想用一个公式来对待。 因此,如果将0列入公式,就会返回2,如果加入2,则返回0(与1和3相同)。
原因是(而且与方案拟定有关),我想在一席之地正好相反,而不必作任何改动。 但是,这意味着任何公式(如果可能的话)都必须不成体系,这样,其效率要比在转换时使用效率更高。
我有4个零3个,是一个大体(目标),我想用一个公式来对待。 因此,如果将0列入公式,就会返回2,如果加入2,则返回0(与1和3相同)。
原因是(而且与方案拟定有关),我想在一席之地正好相反,而不必作任何改动。 但是,这意味着任何公式(如果可能的话)都必须不成体系,这样,其效率要比在转换时使用效率更高。
公式非常简单:
n = n ^ 2;
参照价值0至3,以及排他性或变迁方式:
n ^10
---------------
0 = 00 : 10 = 2
1 = 01 : 11 = 3
2 = 10 : 00 = 0
3 = 11 : 01 = 1
测试(C#):
for (int n = 0; n <= 3; n++) {
Console.WriteLine("{0} : {1}", n, n ^ 2);
}
产出:
0 : 2
1 : 3
2 : 0
3 : 1
int newValue = 3 - originalValue;
或许可以投身于你身上。
Edit: Sorry, this swaps 0 <=> 3 and 1 <=> 2,我认为这是相反的。
“0 <”;=> 2和1 <=> 3
int newValue = (originalValue + 2) % 4;
I have the following available: last reported lat,lon w/timestamp target lat,lon estimated time to target heading How can I interpolate an estimated position over time? I know that s enough to ...
I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...
I am having a problem handling large numbers. I need to calculate the log of a very large number. The number is the product of a series of numbers. For example: log(2x3x66x435x444) though my actual ...
I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...
I m using Electro in Lua for some 3D simulations, and I m running in to something of a mathematical/algorithmic/physics snag. I m trying to figure out how I would find the "spin" of a sphere of a ...
I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2 s value (1.5) is more ...
I ve implemented this method in Javascript and I m roughly 2.5% out and I d like to understand why. My input data is an array of points represented as latitude, longitude and the height above the ...
Given a coordinate (lat, long), I am trying to calculate a square bounding box that is a given distance (e.g. 50km) away from the coordinate. So as input I have lat, long and distance and as output I ...