Feedback on my Calculator

Hello :magic_wand:. There’s this calculator have been working on for over a month’s worth of days. It is still an ongoing project, but I really want to know what you guys think of it so far. I’m fairly new to programming, I just started learning at around the end of last year. So I am willing to learn a lot from this forum.

The experience is a bit of a mess, and I apologise for that.
Calculator - A.Sidney’s Test Place

What can my calculator do so far?

  • Compute values with four basic operations
  • Use the Last Answer function for continued calculations

I am planning on adding way more functionality to my calculator, such as memory and storage functions, exponents and roots, logarithms, trigonometric functions, graphing mode, factorials, permutations and combination functions and much more. My aim is to make this the best Roblox calculator with the most comprehensive features.
In that sense, I would really appreciate your feedback, thoughts, pointers and advise about this project of mine.

Open-source?
I might consider creating a repository on GitHub and making my code public and open-source if this project goes well. But as of now… my code is not looking its prettiest.
GitHub repository(addTextClrScreen.lua)

6 Likes

Uh oh:

On a serious not though this is quite impressive for a begineer.
But since i can’t see your code. The only thing i can complain about is the UI.

1 Like

Decimals seem to be the Luau programming language’s kryptonite (happens sometimes in everyone’s scripts)

this is actually really good! keep it up!

here are some errors in console , if it helps

2 Likes

oh yeah, the UI is terrible I’m very aware :sweat_smile:
I’ve made a repository in GitHub.
GitHub repo - addTextClrScreen.lua
I tried my best to annotate almost everything and make it look neat and easy to follow through, but its quite messy in a few areas, sorry.

I’ve never encountered that bug before in testing… I’ll look into what’s the problem and try to fix it asap

1 Like

Thank you for the feedback, I’ll look into those errors asap.
Oh okay, I guess I’ll have to find a way around that decimal enigma. Thank you.

1 Like

In this image, the error is at the 15th decimal place:

In @boterflic5’s image, the error is also at the 15th decimal place.
A simple solution to this problem would be to round to the 14th decimal place

local function round(n)
      return math.floor(n*(10^14))/10^14
end

-- Set the answer to round(answer)

Also i have noticed that in your code. You used a lot of pcalls like this:

local success, errorMessage = pcall(function()
     -- Your code here
end)

if success then
   printSuccess()
else
   printError(errorMessage)
end

If you prefer you can use XpCall

local success = xpcall(function()
     -- Your code here
end, printError)

if success then
   printSuccess()
end
1 Like

I believe the xpcall will definitely come in handy. Thank you.

Lua Accuracy Fix

Concerning the decimal enigma, I also saw to it that rounding off was the best solution to producing accurate answers with no weird answers.
But, there was a big problem with the code you suggested. If the user would type other numbers into the calculation(e.g. “0.1+0.2*1000”) it would give a wrong answer. So i took this alternative:

Rounding off the answer to the nearest 11 significant figures

The code I made is in this repository. The code is long, so I figured I would just put a github link for it instead putting it all in a reply

--Summary Code:
local function roundOff(number, significantFigures)
    --code
end
roundOff(answer, 11) -- round off the calculator's answer to the nearest 11 significant figures.

The code is flexible and can be used anywhere to round off numbers to the nearest significant figures.

Here are just a few images of the fix.

1 Like

What’s the use of the current calculator? Because we can just open the Windows 10 one if we have a question when developing, why would we join in the game for that?
image
Also not really sure if it works well but I might be a bit boring.

It doesn’t need to be game-related to qualify as a cool creation. And besides, I could imagine an in-game calculator being useful in some games.

I know this is an old post at this point but it’s good to know in case anyone bumps this post in the future. It’s not a problem with Lua, it’s a problem with binary. You know how 10 divided by 3 is 0.3333333 repeating? In binary, 0.1 (or 1/1010) is 0.0001100110011 repeating. So this needs to get rounded at some point because we don’t have infinite storage. Then, converting back to our human-readable base-10 number system, it’s rounded unpredictably.

The only decimal numbers properly representable in binary are like the markings on American tape measures, inverse powers of two. halves, quarters, eighths, sixteenths, thirty-seconds, sixty-fourths, etc.
0.5 (0.1), 0.75 (0.11), 0.625 (0.101) are all valid binary decimals because they are represented by halves, quarters, and eighths.

There are a few more valid possibilities because of the system we’ve agreed on for representing them (IEEE 754) but for raw binary decimals those are the limits.

1 Like

I’m sorry I had to point this out as a UI designer, but this really needs new UI. This is really cool though!