zoukankan      html  css  js  c++  java
  • 拆分Int64/long 到HighPart/LowPart类型

    今天研究C#调用API,需要把long类型拆分成LowPart和HighPart两部分,所以写了一个方法,来转换这两种类型。

     1using System;
     2
     3namespace Skyfei
     4{
     5    public struct LargeInteger
     6    {
     7        Int32 _LowPart;
     8        Int32 _HighPart;
     9        public Int32 LowPart
    10        {
    11            get
    12            {
    13                return _LowPart;
    14            }

    15            set 
    16            {
    17                _LowPart = value;
    18            }

    19        }

    20    
    21        public Int32 HighPart
    22        {
    23            get
    24            {
    25                return _HighPart;
    26            }

    27            set 
    28            {
    29                _HighPart = value;
    30            }

    31        }

    32    }

    33    /// <summary>
    34    /// LargeInteger 的摘要说明。
    35    /// </summary>

    36    public class LInteger
    37    {
    38        
    39        public LInteger()
    40        {
    41            //
    42            // TODO: 在此处添加构造函数逻辑
    43            //
    44        }

    45
    46        public static long GetLongValue(LargeInteger largeInteger)
    47        {            
    48            return (long)(((ulong)largeInteger.HighPart << 32+ (uint)largeInteger.LowPart);
    49        }

    50
    51        public static LargeInteger GetLargeIntegerValue(long longNumber)
    52        {        
    53            LargeInteger t = new LargeInteger();
    54            t.LowPart = (Int32) longNumber;
    55            t.HighPart = (Int32) (longNumber >> 32);
    56            return t;
    57        }

    58    }

    59}

    60
  • 相关阅读:
    大数据技术之_16_Scala学习_04_函数式编程-基础+面向对象编程-基础
    大数据技术之_16_Scala学习_03_运算符+程序流程控制
    大数据技术之_16_Scala学习_01_Scala 语言概述
    通过创建一个简单的骰子游戏来探究 Python
    在Linux系统中创建SSH服务器别名
    DNS原理及劫持问题
    详细介绍:Kubernetes1.4版本的新功能
    Linux系统中五款好用的日志分析工具
    wc命令——Linux系统高效数据统计工具
    Linux系统内核正式进入5.0版本时代
  • 原文地址:https://www.cnblogs.com/skyfei/p/186756.html
Copyright © 2011-2022 走看看