How to make my calculator more efficient?

this is actually amazing

Please help it’s been two days and I’ve had no help at all

1 Like

I’m completely lost on what it is you’re trying to achieve in this post

Alright man, here’s some dangerous code which can allow you to do any calculator operation! Be careful when using this as if any client has access to its input, it could be a security flaw for your game!

local function calculate(operation)
    return loadstring("return ".. operation)()
end

With this function, you can calculate any operation like this: calculate("1+1"), or calculate("(2+3+4+5)-6-7"). Try it out and let me know if this satisfies what you want!

1 Like

Loadsting is not available. Are you trolling?

1 Like

Make a calculator. Could do amazing things.

1 Like

A TI-84 or basic arithmetic? Please be more specific about your goal

image

I see the problem, you need to account for if there are 3 numbers, hope this helps!

image

1 Like

What kind of advanced sorcery is this

2 Likes

What if I want to use four numbers though…

1 Like

Sorry, out of my expertise, good luck though!

With my function, you could run for any a,b,c,d in decimals, calculate("a+b+c+d")!

I appreciate the attempt. May we both become the greatest coders one day.

1 Like

Intriguing. So I can calculate slope by running the formula Y=MX+B? Very intriguing… indeed!

1 Like

Unfortunately, since it is still loaded in as a roblox string, it needs to be formatted the same way you’d type it in a script. And according to my knowledge, if you have two numbers M and X each containing a different value, to calculate their product you can’t write MX! You need to write instead M*X.
Hope this helps!

Ah… the folly of man. I guess a calculator is impossible then.
image

1 Like

You shouldn’t be devastated by this result! On the contrary, writing M*X instead of MX has its own very advantages. Imagine for some reason you already have a value assigned to MX, M and X. If you want to calculate the product between M and X, you would indeed need to show that you don’t want the value contained in MX! For that, you use an operator (as always), and in roblox, it’s the * operator for multiplication.
Hope this helped!

I am envious of your optimism (definition for optimism down below for the foreign speakers) but I fear that it is impossible. Perhaps computers were not designed for calculators.

1 Like