zoukankan      html  css  js  c++  java
  • 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 = 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 = 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;

  • 相关阅读:
    iOS-导航条
    iOS-存储
    iOS-模型传递
    iOS-日期相关
    iOS-UIViewController
    iOS-loadView方法
    iOS-UIWindow
    Spring 测试
    Spring条件注解@Conditional
    Spring多线程
  • 原文地址:https://www.cnblogs.com/rexzhao/p/7239294.html
Copyright © 2011-2022 走看看