Unity not giving correct solution to equation

I’m attempting to make a shmup wave spawner object that can spawn enemies in set patterns – currently working on the “greater than” shape: >
I came up with a formula that works in google sheets - the basic calculator that comes w/ windows - and everywhere else – Unity, however, decides to give the wrong answer.
The image attached - shows my google sheet - where I came up w/ the equation and tested a few values.
On the right side, I simplify things and just Debug.Log the equation w/ preset values… and show the console result.

what should be 3.4, 2.3, 1.1 - is somehow 4, 4, 4

What gives?

Hi @dalessan9

Try adding “f” after your numbers.

Currently your numbers will be int numbers instead of float number.

So change 4 to 4f and so on.

Otherwise you’ll divide 4 by 7 and result will be whole numbers, see example below:

Debug.Log("Calc ints:" + 4 / 7); 

// Calc ints:0

Debug.Log("Calc floats:" + 4f / 7f); 

// Calc floats:0.5714286

kind of infuriating to have to specify that w/ generic numbers used in a formula

  • I’d call it a bug - but that’s probably built in to C#

another one of those - assume it’s stupid - and you’re probably right - type of things
thanks