本文整理匯總了VB.NET中System.Numerics.BigInteger.Explicit操作符的典型用法代碼示例。如果您正苦於以下問題:VB.NET BigInteger.Explicit操作符的具體用法?VB.NET BigInteger.Explicit怎麽用?VB.NET BigInteger.Explicit使用的例子?那麽, 這裏精選的操作符代碼示例或許可以為您提供幫助。您也可以進一步了解該操作符所在類System.Numerics.BigInteger
的用法示例。
在下文中一共展示了BigInteger.Explicit操作符的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: decimals
' Explicit Decimal to BigInteger conversion
Dim decimals() As Decimal = { Decimal.MinValue, -15632.991d, 9029321.12d,
Decimal.MaxValue }
Dim number As BigInteger
Console.WriteLine("{0,35} {1,35}", "Decimal", "BigInteger")
Console.WriteLine()
For Each value As Decimal In decimals
number = CType(value, BigInteger)
Console.WriteLine("{0,35} {1,35}",
value, number)
Next
輸出:
Decimal BigInteger -79228162514264337593543950335 -79228162514264337593543950335 -15632.991 -15632 9029321.12 9029321 79228162514264337593543950335 79228162514264337593543950335
示例2: doubles
Dim doubles() As Double = { Double.MinValue, -1.430955172e03, 2.410970032e05,
Double.MaxValue, Double.PositiveInfinity,
Double.NegativeInfinity, Double.NaN }
Dim number As BigInteger
Console.WriteLine("{0,37} {1,37}", "Double", "BigInteger")
Console.WriteLine()
For Each value As Double In doubles
Try
number = CType(value, BigInteger)
Console.WriteLine("{0,37} {1,37}", value, number)
Catch e As OverflowException
Console.WriteLine("{0,37} {1,37}", value, "OverflowException")
End Try
Next
輸出:
Double BigInteger -1.79769313486232E+308 -1.7976931348623157081452742373E+308 -1430.955172 -1430 241097.0032 241097 1.79769313486232E+308 1.7976931348623157081452742373E+308 Infinity OverflowException -Infinity OverflowException NaN OverflowException
示例3: CType
' BigInteger to Byte conversion.
Dim goodByte As BigInteger = BigInteger.One
Dim badByte As BigInteger = 256
Dim byteFromBigInteger As Byte
' Convert using CType function.
byteFromBigInteger = CType(goodByte, Byte)
Console.WriteLine(byteFromBigInteger)
' Convert using CByte function.
byteFromBigInteger = CByte(goodByte)
Console.WriteLine(byteFromBigInteger)
' Handle conversion that should result in overflow.
Try
byteFromBigInteger = CType(badByte, Byte)
Console.WriteLine(byteFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badByte, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例4: CType
' BigInteger to Decimal conversion.
Dim goodDecimal As BigInteger = 761652543
Dim badDecimal As BigInteger = CType(Decimal.MaxValue, BigInteger)
badDecimal += BigInteger.One
Dim decimalFromBigInteger As Decimal
' Convert using CType function.
decimalFromBigInteger = CType(goodDecimal, Decimal)
Console.WriteLine(decimalFromBigInteger)
' Convert using CDec function.
decimalFromBigInteger = CDec(goodDecimal)
Console.WriteLine(decimalFromBigInteger)
' Handle conversion that should result in overflow.
Try
decimalFromBigInteger = CType(badDecimal, Decimal)
Console.WriteLine(decimalFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badDecimal, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例5: CType
' BigInteger to Double conversion.
Dim goodDouble As BigInteger = 102.43e22
Dim badDouble As BigInteger = CType(Double.MaxValue, BigInteger)
badDouble = badDouble * 2
Dim doubleFromBigInteger As Double
' Convert using CType function.
doubleFromBigInteger = CType(goodDouble, Double)
Console.WriteLine(doubleFromBigInteger)
' Convert using CDbl function.
doubleFromBigInteger = CDbl(goodDouble)
Console.WriteLine(doubleFromBigInteger)
' Convert an out-of-bounds BigInteger value to a Double.
doubleFromBigInteger = CType(badDouble, Double)
Console.WriteLine(doubleFromBigInteger)
示例6: CType
' Increase a BigInteger so it exceeds Double.MaxValue.
Dim number1 As BigInteger = CType(Double.MaxValue, BigInteger)
Dim number2 As BigInteger = number1
number2 = number2 + 9.999e291
' Compare the BigInteger values for equality.
Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1))
' Convert the BigInteger to a Double.
Dim dbl As Double = CType(number2, Double)
' Display the two values.
Console.WriteLine("BigInteger: {0}", number2)
Console.WriteLine("Double: {0}", dbl)
輸出:
BigIntegers equal: False BigInteger: 1.7976931348623158081352742373E+308 Double: 1.79769313486232E+308
示例7: CType
' BigInteger to Int16 conversion.
Dim goodShort As BigInteger = 20000
Dim badShort As BigInteger = 33000
Dim shortFromBigInteger As Short
' Convert using CType function.
shortFromBigInteger = CType(goodShort, Short)
Console.WriteLine(shortFromBigInteger)
' Convert using CShort function.
shortFromBigInteger = CShort(goodShort)
Console.WriteLine(shortFromBigInteger)
' Handle conversion that should result in overflow.
Try
shortFromBigInteger = CType(badShort, Short)
Console.WriteLine(shortFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badShort, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例8: CType
' BigInteger to Int32 conversion.
Dim goodInteger As BigInteger = 200000
Dim badInteger As BigInteger = 65000000000
Dim integerFromBigInteger As Integer
' Convert using CType function.
integerFromBigInteger = CType(goodInteger, Integer)
Console.WriteLine(integerFromBigInteger)
' Convert using CInt function.
integerFromBigInteger = CInt(goodInteger)
Console.WriteLIne(integerFromBigInteger)
' Handle conversion that should result in overflow.
Try
integerFromBigInteger = CType(badInteger, Integer)
Console.WriteLine(integerFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badInteger, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例9: CType
' BigInteger to Int64 conversion.
Dim goodLong As BigInteger = 2000000000
Dim badLong As BigInteger = BigInteger.Pow(goodLong, 3)
Dim longFromBigInteger As Long
' Convert using CType function.
longFromBigInteger = CType(goodLong, Long)
Console.WriteLine(longFromBigInteger)
' Convert using CLng function.
longFromBigInteger = CLng(goodLong)
Console.WriteLine(longFromBigInteger)
' Handle conversion that should result in overflow.
Try
longFromBigInteger = CType(badLong, Long)
Console.WriteLine(longFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badLong, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例10: CType
' BigInteger to SByte conversion.
Dim goodSByte As BigInteger = BigInteger.MinusOne
Dim badSByte As BigInteger = -130
Dim sByteFromBigInteger As SByte
' Convert using CType function.
sByteFromBigInteger = CType(goodSByte, SByte)
Console.WriteLine(sByteFromBigInteger)
' Convert using CSByte function.
sByteFromBigInteger = CSByte(goodSByte)
Console.WriteLine(sByteFromBigInteger)
' Handle conversion that should result in overflow.
Try
sByteFromBigInteger = CType(badSByte, SByte)
Console.WriteLine(sByteFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badSByte, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例11: CType
' BigInteger to Single conversion.
Dim goodSingle As BigInteger = 102.43e22
Dim badSingle As BigInteger = CType(Single.MaxValue, BigInteger)
badSingle = badSingle * 2
Dim singleFromBigInteger As Single
' Convert using CType function.
singleFromBigInteger = CType(goodSingle, Single)
Console.WriteLine(singleFromBigInteger)
' Convert using CSng function.
singleFromBigInteger = CSng(goodSingle)
Console.WriteLine(singleFromBigInteger)
' Convert an out-of-bounds BigInteger value to a Single.
singleFromBigInteger = CType(badSingle, Single)
Console.WriteLine(singleFromBigInteger)
示例12: CType
' Increase a BigInteger so it exceeds Single.MaxValue.
Dim number1 As BigInteger = CType(Single.MaxValue, BigInteger)
Dim number2 As BigInteger = number1
number2 = number2 + 9.999e30
' Compare the BigInteger values for equality.
Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1))
' Convert the BigInteger to a Single.
Dim sng As Single = CType(number2, Single)
' Display the two values.
Console.WriteLine("BigInteger: {0}", number2)
Console.WriteLine("Single: {0}", sng)
輸出:
BigIntegers equal: False BigInteger: 3.4028235663752885981170396038E+38 Single: 3.402823E+38
示例13: CType
' BigInteger to UInt16 conversion.
Dim goodUShort As BigInteger = 20000
Dim badUShort As BigInteger = 66000
Dim uShortFromBigInteger As UShort
' Convert using CType function.
uShortFromBigInteger = CType(goodUShort, UShort)
Console.WriteLine(uShortFromBigInteger)
' Convert using CUShort function.
uShortFromBigInteger = CUShort(goodUShort)
Console.WriteLine(uShortFromBigInteger)
' Handle conversion that should result in overflow.
Try
uShortFromBigInteger = CType(badUShort, UShort)
Console.WriteLine(uShortFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badUShort, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例14: CType
' BigInteger to UInt32 conversion.
Dim goodUInteger As BigInteger = 200000
Dim badUInteger As BigInteger = 65000000000
Dim uIntegerFromBigInteger As UInteger
' Convert using CType function.
uIntegerFromBigInteger = CType(goodInteger, UInteger)
Console.WriteLine(uIntegerFromBigInteger)
' Convert using CUInt function.
uIntegerFromBigInteger = CUInt(goodInteger)
Console.WriteLine(uIntegerFromBigInteger)
' Handle conversion that should result in overflow.
Try
uIntegerFromBigInteger = CType(badUInteger, UInteger)
Console.WriteLine(uIntegerFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badUInteger, vbCrLf, e.Message)
End Try
Console.WriteLine()
示例15: CType
' BigInteger to UInt64 conversion.
Dim goodULong As BigInteger = 2000000000
Dim badULong As BigInteger = BigInteger.Pow(goodULong, 3)
Dim uLongFromBigInteger As ULong
' Convert using CType function.
uLongFromBigInteger = CType(goodULong, ULong)
Console.WriteLine(uLongFromBigInteger)
' Convert using CULng function.
uLongFromBigInteger = CULng(goodULong)
Console.WriteLine(uLongFromBigInteger)
' Handle conversion that should result in overflow.
Try
uLongFromBigInteger = CType(badULong, ULong)
Console.WriteLine(uLongFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}", _
badULong, vbCrLf, e.Message)
End Try
Console.WriteLine()