Class Util.Base
Base of number.
數字進制。
Inheritance
Namespace: Votanic
Assembly: Votanic.Core.dll
Syntax
public class Base
Fields
Base128
Base 128.
一百二十八進制。
Declaration
public const string Base128 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`~ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψω!@#$%^&*()[{]};:"
Field Value
Type | Description |
---|---|
System.String |
Base16
Hex.
十六進制。
Declaration
public const string Base16 = "0123456789ABCDEF"
Field Value
Type | Description |
---|---|
System.String |
Base32
Base 32.
三十二進制。
Declaration
public const string Base32 = "0123456789ABCDEFGHIJKLMNOPQRSTUV"
Field Value
Type | Description |
---|---|
System.String |
Base36
Base 36.
三十六進制。
Declaration
public const string Base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Field Value
Type | Description |
---|---|
System.String |
Base64
Base 64.
六十四進制。
Declaration
public const string Base64 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`~"
Field Value
Type | Description |
---|---|
System.String |
Methods
Compress(Object, UInt32)
Compress a number by Base128 format.
將一個數字以一百二十八進制格式壓縮。
Compress(1.01)
Declaration
public static string Compress(object value, uint fromBase = 10U)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The number |
System.UInt32 | fromBase | Original base |
Returns
Type | Description |
---|---|
System.String |
Convert(Object, UInt32, UInt32)
Convert a number from its base to other base.
將一個數字為它的進制轉為其他進制。
Convert("-123.456", 10, 16)
Declaration
public static string Convert(object value, uint fromBase, uint toBase)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The number |
System.UInt32 | fromBase | Original base |
System.UInt32 | toBase | Target base |
Returns
Type | Description |
---|---|
System.String |
Decompress(String, UInt32)
Decompress a number from Base128 format.
將一個數字以一百二十八進制格式解壓。
Decompress(1.1)
Declaration
public static string Decompress(string value, uint toBase = 10U)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The number |
System.UInt32 | toBase | Target base |
Returns
Type | Description |
---|---|
System.String |
Format(Object, Int32, Int32)
Format a number to target digits and decimals.
將一個數的格式化為目標的整數位及小數位。
Format(123.456, 4, 0)
Declaration
public static string Format(object value, int digits = -1, int decimals = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The number |
System.Int32 | digits | Number of digits (-1 = Ignore this part) |
System.Int32 | decimals | Number of decimals (-1 = Ignore this part) |
Returns
Type | Description |
---|---|
System.String |
FromBase10(Double, UInt32)
Convert a decimal number to other base.
將一個十進制數字轉為其他進制。
FromBase10(-123.456, 16)
Declaration
public static string FromBase10(double value, uint toBase)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The number |
System.UInt32 | toBase | Target base |
Returns
Type | Description |
---|---|
System.String |
ToBase10(String, UInt32)
Convert a number from its base to Decimal.
將一個數由它的進制轉為十進制。
ToBase10("-1001.01", 2)
Declaration
public static double ToBase10(string value, uint fromBase)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The number |
System.UInt32 | fromBase | Original base |
Returns
Type | Description |
---|---|
System.Double |