import { parseBigInt } from "./parseBigInt.js";
function numberToBigInt(value, precision = 18n) {
  if (precision < 0n) throw new Error(`numberToBigInt: precision must be positive, got ${precision}`);
  if (value % 1 !== 0 && precision >= 1n) {
    const parsedValue = parseBigInt(String(value), precision);
    if (parsedValue === null) {
      throw new Error(`numberToBigInt: failed to parse ${value} as a bigint with precision ${precision}`);
    }
    return parsedValue;
  } else {
    const precisionFactor = 10n ** precision;
    return BigInt(Math.trunc(value)) * precisionFactor;
  }
}
export {
  numberToBigInt
};
