@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
31 lines (30 loc) • 981 B
TypeScript
/**
* @static
*/
export default class BitUtils {
private constructor();
/**
* @deprecated not sure it has ever made sense to have it
* @returns a number in range ```[ 0 , 255 ]``` ( ```[ 0b0000_0000, 0b1111_1111 ]``` ) based on the first byte
*/
static getFirstByte(bits: bigint): number;
/**
* @deprecated use ```andMaskOfLength``` instead
*/
static andMaskOfLengthInt(n: number): bigint;
/**
* returns a ```bigint``` of that as the last ```n``` bits setted to ones;
*
* example
* ```ts
* BitUtils.getMaskOfLength( 7 ) === Bigint( 0b0111_1111 ); // true
* ```
*/
static andMaskOfLength(n: bigint): bigint;
static getNLastBits(fromNuber: bigint, nBits: bigint): bigint;
/**
* @returns the number of bits from the first setted to ```1``` on the left up until the end
*/
static getNOfUsedBits(bits: bigint): number;
static minBytesRequired(bigint: bigint): number;
}