2022-09-05 16:57:11 -04:00
|
|
|
import type { BytesLike } from "./data.js";
|
2022-09-15 22:58:45 -04:00
|
|
|
/**
|
|
|
|
* Any type that can be used where a numeric value is needed.
|
|
|
|
*/
|
2023-02-02 04:05:47 -05:00
|
|
|
export type Numeric = number | bigint;
|
2022-09-15 22:58:45 -04:00
|
|
|
/**
|
|
|
|
* Any type that can be used where a big number is needed.
|
|
|
|
*/
|
2023-02-02 04:05:47 -05:00
|
|
|
export type BigNumberish = string | Numeric;
|
2022-09-05 16:57:11 -04:00
|
|
|
/**
|
2022-11-30 15:44:23 -05:00
|
|
|
* Convert %%value%% from a twos-compliment representation of %%width%%
|
|
|
|
* bits to its value.
|
|
|
|
*
|
|
|
|
* If the highest bit is ``1``, the result will be negative.
|
2022-09-05 16:57:11 -04:00
|
|
|
*/
|
|
|
|
export declare function fromTwos(_value: BigNumberish, _width: Numeric): bigint;
|
|
|
|
/**
|
2022-11-30 15:44:23 -05:00
|
|
|
* Convert %%value%% to a twos-compliment representation of
|
|
|
|
* %%width%% bits.
|
|
|
|
*
|
|
|
|
* The result will always be positive.
|
2022-09-05 16:57:11 -04:00
|
|
|
*/
|
|
|
|
export declare function toTwos(_value: BigNumberish, _width: Numeric): bigint;
|
|
|
|
/**
|
|
|
|
* Mask %%value%% with a bitmask of %%bits%% ones.
|
|
|
|
*/
|
|
|
|
export declare function mask(_value: BigNumberish, _bits: Numeric): bigint;
|
2022-09-15 22:58:45 -04:00
|
|
|
/**
|
2023-02-12 22:14:26 -05:00
|
|
|
* Gets a BigInt from %%value%%. If it is an invalid value for
|
2022-09-15 22:58:45 -04:00
|
|
|
* a BigInt, then an ArgumentError will be thrown for %%name%%.
|
|
|
|
*/
|
|
|
|
export declare function getBigInt(value: BigNumberish, name?: string): bigint;
|
2023-06-01 17:52:58 -04:00
|
|
|
/**
|
|
|
|
* Returns %%value%% as a bigint, validating it is valid as a bigint
|
|
|
|
* value and that it is positive.
|
|
|
|
*/
|
2022-12-09 18:24:58 -05:00
|
|
|
export declare function getUint(value: BigNumberish, name?: string): bigint;
|
2022-09-05 16:57:11 -04:00
|
|
|
export declare function toBigInt(value: BigNumberish | Uint8Array): bigint;
|
2022-09-15 22:58:45 -04:00
|
|
|
/**
|
|
|
|
* Gets a //number// from %%value%%. If it is an invalid value for
|
|
|
|
* a //number//, then an ArgumentError will be thrown for %%name%%.
|
|
|
|
*/
|
|
|
|
export declare function getNumber(value: BigNumberish, name?: string): number;
|
2022-11-30 15:44:23 -05:00
|
|
|
/**
|
|
|
|
* Converts %%value%% to a number. If %%value%% is a Uint8Array, it
|
|
|
|
* is treated as Big Endian data. Throws if the value is not safe.
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
export declare function toNumber(value: BigNumberish | Uint8Array): number;
|
|
|
|
/**
|
|
|
|
* Converts %%value%% to a Big Endian hexstring, optionally padded to
|
|
|
|
* %%width%% bytes.
|
|
|
|
*/
|
2022-12-09 18:24:58 -05:00
|
|
|
export declare function toBeHex(_value: BigNumberish, _width?: Numeric): string;
|
2022-09-05 16:57:11 -04:00
|
|
|
/**
|
|
|
|
* Converts %%value%% to a Big Endian Uint8Array.
|
|
|
|
*/
|
2022-12-09 18:24:58 -05:00
|
|
|
export declare function toBeArray(_value: BigNumberish): Uint8Array;
|
2022-09-15 22:58:45 -04:00
|
|
|
/**
|
|
|
|
* Returns a [[HexString]] for %%value%% safe to use as a //Quantity//.
|
|
|
|
*
|
|
|
|
* A //Quantity// does not have and leading 0 values unless the value is
|
|
|
|
* the literal value `0x0`. This is most commonly used for JSSON-RPC
|
|
|
|
* numeric values.
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
export declare function toQuantity(value: BytesLike | BigNumberish): string;
|
|
|
|
//# sourceMappingURL=maths.d.ts.map
|