Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- im going to make a complete rounding function
- function supernumber(y)
- local x = tonumber(y)
- if x > 0 and x < 10 then
- local sup = {"¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹"}
- return sup[x]
- else
- return "⁰"
- end
- end
- function supernumbers(x)
- local y = tostring(x)
- local k = ""
- for i=1,#y do
- k = k..supernumber(string.sub(y,i,i))
- end
- return k
- end
- function round(number,deci)
- local num = tostring(number)
- local num2 = ""
- local num3 = ""
- local num4
- local savevar1 = ""
- for i=1,#num do
- if string.sub(num,i,i+1):lower() == "e+" then
- savevar1 = string.sub(num,i+2)
- num2 = string.sub(num,1,i-1)
- break
- end
- end
- if num2 ~= "" then num = num2 end
- for i=1,#num do
- if string.sub(num,i,i) == "." then
- num3 = tonumber(string.sub(num,deci+i+1,deci+i+1))
- num4 = tonumber(string.sub(num,deci+i,deci+i))
- if num3 == "" or num3 == nil then break end
- if num3 >= 5 then
- num = string.sub(num,1,i-1+deci)..tostring(num4+1)
- else
- num = string.sub(num,1,i-1+deci)..tostring(num4)
- end
- end
- end
- if savevar1 ~= "" then
- num = num.." * 10"..supernumbers(savevar1)
- end
- return num
- end
- local moles = 0.2281928493
- local molar_mass = 44.0098 -- grams require molar_mass
- local atoms = 3
- local roundto = 2
- local particles = moles*(6.02*10^23)
- local grams = moles*molar_mass
- local liters = moles*22.4
- print("Particles: "..round(particles,roundto))
- print("Grams: "..round(grams,roundto))
- print("Liters: "..round(liters,roundto))
- print("Atoms: "..round(particles*atoms,roundto))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement