# Block code bug thing

Had to post this on Blueboat, since Blackhole927 has a draft saved at the moment.

Can someone see if they also experience this bug?

2 Likes

Lemme try.

1 Like

I experience it when I replicate it.
I also tried switching Green and Yellow, and it was printed out as 0

Yeah, I got 0 too.

resolved (on discord)!

Just tried swapping them as well and it worked.

This is still a bug- if the first number inputted is negative gimkit fails to do the math correctly

I think this is how it works. The two strings are added, converted to a number to be divided by 2, then Red is set to that value. Do Green and Yellow need to be strings?

They do need to be strings- this code is an excerpt from a much larger project, where the numbers have to be strings in order to save memory.

What I donâ€™t get is why (-20 + 20)/2 = -1010, but (20 + -20)/2 = 0

How do strings store the negative signs?

I did not know that text cost less than numbers, thank you.
Strings canâ€™t be added like numbers, so â€ś-20â€ť + â€ś20â€ť = â€ś-2020â€ť.
In order to be divided in half, it needs to be converted into a number.
`-2020/2 = -1010`
For `"20" + "-20"` it comes out as `"20-20"` because it is a string. It is then converted into an expression. However, for it to be divided by 2, the expression must be simplified, so `(20-20)/2 = ?` â†’ `0/2 = 0`
Is that the only code needed in that trigger? Because maybe you could use
`"-(Absolute Value(Green))"` if you have enough room

Well- what confuses me is that -20 + 20 = 0.
The -1010 only happened when I divided by 2.

But Green and Yellow are strings right? So they arenâ€™t added as numbers, but like a `create text with` block. Isnâ€™t the `+` operation the only math operation we can use on text?

I was confused when you typed green since Iâ€™m red/green colorblind lol.

Would this help?

Yeah I got it now. Thanks.

Wdym you had to post this on Blueboat?

Blueboat is blackholeâ€™s alt

K thanks

Donâ€™t randomly delete things that do contribute to the conversation. It just makes it harder to read things.