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.

2 Likes

Screenshot 2024-01-28 3.48.30 PM
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.