Der aktuelle Code ist wie folgt.
Code: Select all
public static UInt32_Register Mul10(UInt32_Register rA)
{
UInt32_Register rX = 0;
byte sum = 0;
byte report = 0;
rX[0] = 0;
rX[1] = rA[0];
rX[2] = rA[1];
for (int i = 3; i < 32; i++)
{
sum = (byte) (report + rA[i - 1] + rA[i - 3]);
if (sum > 1)
{
report = 1;
rX[i] = 0;
}
else
{
report = 0;
rX[i] = sum;
}
}
return rX;
}
Der Code von UInt32_Register ist wie folgt
Code: Select all
public struct UInt32_Register
{
private UInt32 iValue;
public static implicit operator UInt32_Register(UInt32 value)
{
return new UInt32_Register { iValue = value };
}
public static implicit operator UInt32(UInt32_Register value)
{
return value.iValue;
}
public byte this[int index]
{
get
{
// return value of bit in position 'index' as 'byte' integer
return (byte)((iValue >> index) & 1);
}
set
{
// assign bit value to 1 or 0
if (value == 1)
{
iValue = iValue | ((UInt32)1 = 0; i--)
{
if (R.FromTo(n-1,i) >= D)
{
Q[i] = 1;
R.FromTo(n-1,i) = R.FromTo(n-1,i) - D;
Code: Select all
FromTo()Die Funktion Aber die letzte Zeile ist im linken Teil der Zuweisung nicht korrekt.
Wie kann ich eine Eigenschaft definieren, die 2 Parameter akzeptiert?
Ich habe versucht, den folgenden Code zu verwenden:
Code: Select all
public UInt32 FromToX_1test
{
get(int iFrom, int iTo)
{
int nShiftLeft = 8 * sizeof(UInt32) - 1 - iFrom;
int nShiftRight = nShiftLeft + iTo;
UInt32 nX = (iValue > nShiftRight;
return nX;
}
set(int iFrom, int iTo, byte value)
{
...
}
}
}
Code: Select all
public UInt32 FromToX_2test(int iFrom, int iTo)
{
get
{
int nShiftLeft = 8 * sizeof(UInt32) - 1 - iFrom;
int nShiftRight = nShiftLeft + iTo;
UInt32 nX = (iValue > nShiftRight;
return nX;
}
set
{
...
}
}
Was muss ich tun, um die folgende Zuweisung ohne Fehler bei der Kompilierung zu schreiben?
Code: Select all
R.FromTo(n-1,i) = R.FromTo(n-1,i) - D;
Warnung: Ich suche keine Lösung für meinen Implementierungsalgorithmus. Als Beispiele dienen Teile des Multiplikations- und Divisionsalgorithmus.
Mobile version