Last active
May 16, 2024 13:29
-
-
Save hos/bf6006ff3911a46ebc7b5263de30c611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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