當前位置: 首頁>>代碼示例>>C#>>正文


C# BigInteger.LeftShift操作符代碼示例

本文整理匯總了C#中System.Numerics.BigInteger.LeftShift操作符的典型用法代碼示例。如果您正苦於以下問題:C# BigInteger.LeftShift操作符的具體用法?C# BigInteger.LeftShift怎麽用?C# BigInteger.LeftShift使用的例子?那麽, 這裏精選的操作符代碼示例或許可以為您提供幫助。您也可以進一步了解該操作符所在System.Numerics.BigInteger的用法示例。


在下文中一共展示了BigInteger.LeftShift操作符的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1:

BigInteger number = BigInteger.Parse("-9047321678449816249999312055");
Console.WriteLine("Shifting {0} left by:", number);
for (int ctr = 0; ctr <= 16; ctr++)
{
   BigInteger newNumber = number << ctr;
   Console.WriteLine(" {0,2} bits: {1,35} {2,30}", 
                     ctr, newNumber, newNumber.ToString("X"));
}
開發者ID:.NET開發者,項目名稱:System.Numerics,代碼行數:8,代碼來源:BigInteger.LeftShift

輸出:

Shifting -9047321678449816249999312055 left by:
0 bits:       -9047321678449816249999312055       E2C43B1D0D6F07D2CC1FBB49
1 bits:      -18094643356899632499998624110       C588763A1ADE0FA5983F7692
2 bits:      -36189286713799264999997248220       8B10EC7435BC1F4B307EED24
3 bits:      -72378573427598529999994496440      F1621D8E86B783E9660FDDA48
4 bits: -1.4475714685519705999998899288E+29      E2C43B1D0D6F07D2CC1FBB490
5 bits: -2.8951429371039411999997798576E+29      C588763A1ADE0FA5983F76920
6 bits: -5.7902858742078823999995597152E+29      8B10EC7435BC1F4B307EED240
7 bits:  -1.158057174841576479999911943E+30     F1621D8E86B783E9660FDDA480
8 bits: -2.3161143496831529599998238861E+30     E2C43B1D0D6F07D2CC1FBB4900
9 bits: -4.6322286993663059199996477722E+30     C588763A1ADE0FA5983F769200
10 bits: -9.2644573987326118399992955443E+30     8B10EC7435BC1F4B307EED2400
11 bits: -1.8528914797465223679998591089E+31    F1621D8E86B783E9660FDDA4800
12 bits: -3.7057829594930447359997182177E+31    E2C43B1D0D6F07D2CC1FBB49000
13 bits: -7.4115659189860894719994364355E+31    C588763A1ADE0FA5983F7692000
14 bits: -1.4823131837972178943998872871E+32    8B10EC7435BC1F4B307EED24000
15 bits: -2.9646263675944357887997745742E+32   F1621D8E86B783E9660FDDA48000
16 bits: -5.9292527351888715775995491484E+32   E2C43B1D0D6F07D2CC1FBB490000

示例2:

BigInteger number = BigInteger.Parse("-9047321678449816249999312055");
Console.WriteLine("Shifting {0} left by:", number);
for (int ctr = 0; ctr <= 16; ctr++)
{
   BigInteger newNumber = BigInteger.Multiply(number, BigInteger.Pow(2, ctr));
   Console.WriteLine(" {0,2} bits: {1,35} {2,30}", 
                     ctr, newNumber, newNumber.ToString("X"));
}
開發者ID:.NET開發者,項目名稱:System.Numerics,代碼行數:8,代碼來源:BigInteger.LeftShift

輸出:

Shifting -9047321678449816249999312055 left by:
0 bits:       -9047321678449816249999312055       E2C43B1D0D6F07D2CC1FBB49
1 bits:      -18094643356899632499998624110       C588763A1ADE0FA5983F7692
2 bits:      -36189286713799264999997248220       8B10EC7435BC1F4B307EED24
3 bits:      -72378573427598529999994496440      F1621D8E86B783E9660FDDA48
4 bits: -1.4475714685519705999998899288E+29      E2C43B1D0D6F07D2CC1FBB490
5 bits: -2.8951429371039411999997798576E+29      C588763A1ADE0FA5983F76920
6 bits: -5.7902858742078823999995597152E+29      8B10EC7435BC1F4B307EED240
7 bits:  -1.158057174841576479999911943E+30     F1621D8E86B783E9660FDDA480
8 bits: -2.3161143496831529599998238861E+30     E2C43B1D0D6F07D2CC1FBB4900
9 bits: -4.6322286993663059199996477722E+30     C588763A1ADE0FA5983F769200
10 bits: -9.2644573987326118399992955443E+30     8B10EC7435BC1F4B307EED2400
11 bits: -1.8528914797465223679998591089E+31    F1621D8E86B783E9660FDDA4800
12 bits: -3.7057829594930447359997182177E+31    E2C43B1D0D6F07D2CC1FBB49000
13 bits: -7.4115659189860894719994364355E+31    C588763A1ADE0FA5983F7692000
14 bits: -1.4823131837972178943998872871E+32    8B10EC7435BC1F4B307EED24000
15 bits: -2.9646263675944357887997745742E+32   F1621D8E86B783E9660FDDA48000
16 bits: -5.9292527351888715775995491484E+32   E2C43B1D0D6F07D2CC1FBB490000


注:本文中的System.Numerics.BigInteger.LeftShift操作符示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。