Skip to content

Instantly share code, notes, and snippets.

@hos
Last active May 16, 2024 13:29
Show Gist options
  • Save hos/bf6006ff3911a46ebc7b5263de30c611 to your computer and use it in GitHub Desktop.
Save hos/bf6006ff3911a46ebc7b5263de30c611 to your computer and use it in GitHub Desktop.
export function bigIntP(value: bigint, percentage: number, scalingFactor = 1000000000): bigint {
const scaledPercentage = BigInt(Math.round(percentage * 100 * scalingFactor))
const result = (value * scaledPercentage) / (BigInt(100) * BigInt(scalingFactor))
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment