I need some help please, I port a serial number generator over to B4J from Delphi. But unfortunately the calculation is not correct. The max number length is 10 so it should fit into long/double.
can somebody have look ?
THX
the pascal numbers are:
103
6719591
6722872
6722921
2500730217
2501951276
2501951325
712783709
713131747
713131796
2912161566
2913583509
b4j has the following
103
6719591
6722872
6722921
-1794237079
-1795113172
-1795113123
710686557
711033571
711033620
-1452012780
-1452721771
-1452721722
not really sure whats going on
can somebody have look ?
THX
B4X:
Dim v AsInt
Dim f,ff,gg As Long
Dim math As Long
math = 54
For v = 0 To 25 Step 2
math=math+Asc("1")
Log(v&" "&math)
f=Bit.ShiftLeft(Asc("1"),0x0b)
ff = Bit.Xor(math,f)
gg= Bit.ShiftLeft(math,0x10)
math=Bit.Xor(ff,gg)
Log(v&" "&math)
math = math +Bit.ShiftRight(math,0x0b)
Log(v&" "&math)
Next
B4X:
I: byte;
math:cardinal;
I:=1;
math:=54; //length*2
while I < 26 do begin
Math:=(math+ord(str[I]));
Math:=(math xor (ord(str[I+1]) shl $0b))xor (math shl $10) ;
Math:=math + (math shr $0b);
I:=I+2;
end;
the pascal numbers are:
103
6719591
6722872
6722921
2500730217
2501951276
2501951325
712783709
713131747
713131796
2912161566
2913583509
b4j has the following
103
6719591
6722872
6722921
-1794237079
-1795113172
-1795113123
710686557
711033571
711033620
-1452012780
-1452721771
-1452721722
not really sure whats going on