I am working on an equation that goes:
gpm = rpm x displacement / 231 =

I got the code correct, but the results can throw a number with 8 decimal places for example… So, how can I limit the result to a maximum of 4 decimal places?

you can’t limit the number of decimal places of a number, but you can convert it to a string keeping only a certain number of decimal places, like with toFixed

This is why I’m glad we have sane people like @ilenia here, they keep me balanced lol

toFixed() is the quickest and cleanest way, but being an overthinker, i had to think your question through.

We want a number of a certain precision (for example, four decimal places, which is ten-thousandths or 10^-4).

We can round a number, but only to the nearest integer.

We would need to move the decimal to the right (in this case, by multiplying by 10,000), round that, and shift the decimal point back (by dividing by 10,000)!