首页 > 代码库 > LockInt
LockInt
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Game.LockNumbers
{
public struct LockInt
{
int vbase;
int vadd;
static readonly int base_flag = 29173;
static readonly int add_flag = 16829;
public int Value{
get { return ( (~vbase + base_flag) >> 1) + vadd + add_flag; }
set
{
var _base = (int)(value * 0.37134f);
vbase = (_base << 1) - base_flag;
vbase = ~vbase;
vadd = (value - _base);
vadd -= add_flag;
}
}
public LockInt(int v)
{
vbase = 0;
vadd = 0;
Value = http://www.mamicode.com/v;
}
public static implicit operator int(LockInt v)
{
return v.Value;
}
public static implicit operator LockInt(int b)
{
LockInt d ;
d.vadd = 0;
d.vbase = 0;
d.Value = http://www.mamicode.com/b;
return d;
}
public static LockInt operator + (LockInt v1, LockInt v2)
{
return v1.Value + v2.Value;
}
public static LockInt operator -(LockInt v1, LockInt v2)
{
return v1.Value - v2.Value;
}
public static LockInt operator *(LockInt v1, LockInt v2)
{
return v1.Value * v2.Value;
}
public static LockInt operator /(LockInt v1, LockInt v2)
{
return v1.Value / v2.Value;
}
}
}
lockint +=1;
locakint =1;
LockInt