簡體   English   中英

如何在Mono C#中將Int64轉換為BigInteger?

[英]How to convert an Int64 to BigInteger in Mono C#?

在MS C#中,以下構造函數工作:

Int64 a = 123;
BigInteger bi = new BigInteger(a);

這在Mono中不起作用。 編譯抱怨它無法從long轉換為BigInteger(CS1502,CS1503)。

反正有沒有這樣做?

請參閱Mono上的BigInteger構造函數, http: //docs.go-mono.com/?link = T%3aaMono.Math.BigInteger%2fC

BigInteger()    
BigInteger(BigInteger)  
BigInteger(byte[])  
BigInteger(uint)    
BigInteger(uint[])  
BigInteger(ulong)   
BigInteger(BigInteger, uint)    
BigInteger(BigInteger.Sign, uint)

沒有構造函數接受long (which is the same as Int64)

嘗試BigInteger bi = new BigInteger((ulong)a);

BigInteger bi = new BigInteger((uint)a);

Mono.Math.BigInteger只有構造函數接受ulong。 是不是System.Numerics.BigInteger你想用嗎?

https://github.com/mono/mono/blob/master/mcs/class/System.Numerics/System.Numerics/BigInteger.cs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM