round with precision
Problem it solves
You want to show a score or measurement with a fixed number of decimal places (like "3.14") instead of a long, messy decimal.
What this block does
Rounds a number to a given number of digits after the decimal point and returns it as text.
The block
Block ID: spriteutilextroundwithprecision
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| x | number | 3.14159 | The number to round |
| digitsAfterDecimal | number | 2 | How many decimal digits to keep |
Returns
string — The rounded value, formatted with the requested number of digits.
Example
let rounded = spriteutils.roundWithPrecision(3.14159, 2) console.log(rounded)
Add the extension
Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.