- encodeName(name) ⇒
string.<uint64>
Encode a name (a base32 string) to a number.
For performance reasons, the blockchain uses the numerical encoding of strings for very common types like account names.
- decodeName(value) ⇒
string
- UDecimalString() ⇒
string
Normalize and validate decimal string (potentially large values). Should avoid internationalization issues if possible but will be safe and throw an error for an invalid number.
Normalization removes extra zeros or decimal.
- UDecimalPad(value, precision) ⇒
string
Ensure a fixed number of decimal places. Safe for large numbers.
- UDecimalImply()
Ensures proper trailing zeros then removes decimal place.
- UDecimalUnimply(value, precision) ⇒
number
Put the decimal place back in its position and return the normalized number string (with any unnecessary zeros or an unnecessary decimal removed).
Encode a name (a base32 string) to a number.
For performance reasons, the blockchain uses the numerical encoding of strings for very common types like account names.
Kind: global function
Returns: string.<uint64>
- - compressed string (from name arg). A string is
always used because a number could exceed JavaScript's 52 bit limit.
See: types.hpp string_to_name
Param | Type | Description |
---|---|---|
name | string |
A string to encode, up to 12 characters long. |
Kind: global function
Param | Type | Description |
---|---|---|
value | Long | String | number |
uint64 |
Normalize and validate decimal string (potentially large values). Should avoid internationalization issues if possible but will be safe and throw an error for an invalid number.
Normalization removes extra zeros or decimal.
Kind: global function
Returns: string
- value
Ensure a fixed number of decimal places. Safe for large numbers.
Kind: global function
Returns: string
- decimal part is added and zero padded to match precision
See: ./format.test.js
Param | Type | Description |
---|---|---|
value | number | string | object.toString |
|
precision | number |
number of decimal places |
Example
UDecimalPad(10.2, 3) === '10.200'
Ensures proper trailing zeros then removes decimal place.
Put the decimal place back in its position and return the normalized number string (with any unnecessary zeros or an unnecessary decimal removed).
Kind: global function
Returns: number
- 1.0000
Param | Type | Description |
---|---|---|
value | string | number | value.toString |
10000 |
precision | number |
4 |