Rounding to the nearest tenth decimal place (SOLVED)

Hello again,

I’m adding a damage formula for my proof of concept, placing it in a function call to update dynamically whenever there’s a change to it (Damage added or removed).

Here is the formula. It’s the same damage formula used in The Binding of Isaac Repentance:

FinalDamage = DamageMultiplier * (BaseDamage * sqrt(TotalDamageUps * 1.2 + 1) + FlatDamageUps)

This formula grants diminishing returns (If damage is added to the TotalDamageUps), which means damage boosts will be increasingly less effective the more you have, to prevent snowballing.

I have the formula written in a function, and it actually works (Function to update damage is called at the beginning of the scene)!


Here’s what happens when I add a damage up of 1 without rounding:

Ew, I don’t want that long ugly number. So I used round(), which does shorten it, but actually, I want the number to be rounded and shortened to just the decimal place at the end. So instead of the damage values reading 5, I want them to read 5.2 (Rounded up from 5.19).

I tried using trunc() and dividing by 100 at the end, but the outcome is an even less savory result:

Now it’s WAY too little damage.

Does anybody know how to adjust the formula to round to a decimal place instead of a whole number?

Thanks ^^

Have you tried roundTo((variable calculations),1)?

1 Like

Awesome, it worked out very well. Thanks a bunch ^^

1 Like

I’m glad it worked, I vaguely remembered having to do that in my first project (a Victris Games tutorial).