Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- I got lazy in math so I made a calculator to literally solve all of my problems
- Amount_of_decimals = 2
- Radius = 0
- Diameter = 3
- function removedec(number)
- num = tostring(number)
- for i=1,#num do
- if string.sub(num,i,i) == "." and string.sub(num,i+1,i+1) == "0" and string.sub(num,i+2,i+2) == "" then
- num = tonumber(string.sub(num,1,i-1))
- break
- end
- end
- return tonumber(num)
- end
- if Radius == 0 then
- Radius = removedec(Diameter/2)
- elseif Diameter == 0 then
- Diameter = Radius*2
- end
- local g = "0."
- for i=1,Amount_of_decimals do
- if i ~= Amount_of_decimals then
- g = g.."0"
- else
- g = g.."1"
- end
- end
- g=tonumber(g)
- ekk = g
- EA = removedec(Radius^2)
- AA = removedec(EA*math.pi)
- AS = tostring(AA)
- for i=1,string.len(AA) do
- if string.sub(AA,i,i) == "." then
- if tonumber(string.sub(AA,i+Amount_of_decimals+1,i+Amount_of_decimals+1)) >= 5 then
- AA = tonumber(string.sub(AA,1,i+Amount_of_decimals))
- AA = AA+ekk
- else
- AA = tonumber(string.sub(AA,1,i+Amount_of_decimals))
- end
- end
- end
- EC = Diameter
- CC = removedec(EC*math.pi)
- for i=1,string.len(CC) do
- if string.sub(CC,i,i) == "." then
- if tonumber(string.sub(CC,i+Amount_of_decimals+1,i+Amount_of_decimals+1)) >= 5 then
- CC = tonumber(string.sub(CC,1,i+Amount_of_decimals))
- CC = CC+ekk
- else
- CC = tonumber(string.sub(CC,1,i+Amount_of_decimals))
- end
- end
- end
- print("Radius: "..Radius.."\nDiameter: "..Diameter.."\nExact Area: "..EA.."\nDec Area: "..AA.."\nExact Circumference: "..EC.."\nDec Circumference: "..CC)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement