Why in the world would this evaluate in this order?

I just don’t get math in Bubble. Every time I think I got it something like this happens.

I get that bubble evaluates left to right. So to deal with that when you need to, I use local Math.js or the Toolbox expression, and often get different answers. But here is one where they both evaluate the same way.
38%20PM

Using parentheses is incredibly hard so I ordered it like this. -1,000,000 times X + Y… and it evaluates the X + Y FIRST!

Why? It’s not left to right, it’s not order of operations. I did the same thing in Toolbox and Math.js.

Bubble would be so wonderful if they dealt with this math issue.

I feel your pain… Definitely a place for improvement.

In the meantime, think of the white text as your expression and the blue text as “bubble”. In your example the bubble stuff is calculating in the manner it knows, left to right, and that is getting inserted into your white stuff.

You should be able to add parentheses (white stuff) to make this work the way you want. And yes, it can be challenging.

3 Likes

Thats a good explanation that fits the facts. Image what cool things could get done if math was easy…or even just easier.

Even though parentheses have been explained to me and I have successfully used them once, I am failing to get them to work. Is there some trick?

I am typing parens first. Then I add text before, after or in between them. But often bubble is asking more to fill a space that should not be filled, or it changes the parentheses to a 0 (which really pisses me off!)

My way (now) of doing it (it can be very confusing) is creating separate actions (I called them calc1, calc2, calc3). I simply make my operations step by step. It work 100% of the time now, but take longer time to create :grinning:

Maybe you should just do this in plain javascript. But why would you need to do this in math.js element?

This would evaluate as you expect in a pure Bubble expression.

Seriously, I think you are making this too hard.

Hang in there @hirscr! I often just drop an Expression element on a page to do calculations that go beyond the basics and write out the formula with static values and parentheses (all in white text;) then go back when it is working and replace the various values with Bubble expressions. Just know that all this is possible, and just a small hurdle in the learning curve. You’ll get it.

This is what I am basically doing. I make expressions for denominators, or other parts of the equation then I put them together in a final step for left to right calculation without parens

do not know html, javascript, java, ruby on rails, css, php, c#, perl, or any other internet related programming language. I know C and am starting with swift. This is why I am relying on bubble to make more complicated website than is possible with website builders. I think this is why most people come to bubble.

I’d like to see this method in a video. Right now I have expression (from toolkit) boxes all over the place. Seems that if I put them in a group and then hide them I lose access to the calculations.

What would be REALLY nice is an equation editor. Jus like there is that rich text editor, a link below the edit field in the edit popup would be amazing (like Microsoft has for word), it places the list of available values on the window somewhere and you drag and drop them into numerator or denominator positions, inside parentheses, on either side of operators, etc etc. A whole separate window. Then you close the window and the expression is right there in whatever format bubble wants.

The other thing that would GREATLY simplify pages with a lot of calculations on it would be allowing access to the number in a text field. Then you wouldn’t have to record this number somewhere in a state or expression to make it available to numerous other expressions.

When this is done, I’ll pay anyone to show me how to simplify what I’m doing using lists or some sort of table or something, this is super tedious.

+1 on this. That would be amazing.

In lieu of that option, a method I’ve been using more and more is creating hidden input fields and performing basic calculations in them and then simply referencing the value of that input.

i.e., your example above, you could have a hidden input named ‘hidden-calcstep1’ that calculates “-10000000*Group Divi economy’s Total Masternode Divi”. Then in your final calculation simply reference it as “hidden-calcstep1’s value + Group Divi General info’s DiviSystem’s Circulating Supply”

I’ve been trying to do the same with toolbox boxes, that I put into a group. Everything is automatically hidden plus I get parentheses.

Well so here is where I am…

https://slater.bubbleapps.io/

And here is what it looks like underneath

I moved to the “toolkit” expression because I could make them smaller on the screen. Otherwise, for the arithmetic operations I was doing, they performed the same. Is there really not a better way. Each one of those is calculating each “cell” in the table.

What about the table… I put even item in its place… I don’t see how I could have done this with lists and repeating groups.