This may be a hackier method than whatever may be included with LuaU’s built-in math functions.
What you can do is check for any decimal points in a number (assuming there is only one), and then checking the first number to the right of that point. If the number is 4 or below, keep the number the same. If the number is 5 or more, add 1 to the overall number and remove everything right to the decimal point.
I don’t know exactly how this would be implemented, but it could potentially work.
You don’t need to round or floor the number for this. Your problem is that your number is enormous. Huge numbers get represented in scientific notation. You’ll need to manually construct the string you want.
Or just use a smaller number. x^97 is kind of absurd.
Actually, I think you might be using math.floor wrong.
local function round(n)
return math.floor(n + 0.5)
end
If you ran this function while passing in a number as n, the number would be rounded to the nearest whole number. I’m not sure if this will work in your case, but it’s worth a try.
Here’s how you would most likely use it -
local function round(n)
return math.floor(n + 0.5)
end
local expNeeded = round() -- insert number your trying to round
-- then you can do whatever you want with expNeeded afterward.
Well if you really want a huge number you could store several smaller numbers and then patch them together to display the massive number. I believe this is what Cookie Clicker does.
local hundreds = 000
local thousands = 000
local millions = 000
function add(n)
hundreds = hundreds + n
-- carry over to thousands
thousands = thousands + math.floor(hundreds/1000)
hundreds = hundreds % 1000
-- carry over to millions
millions = millions + math.floor(thousands/1000)
thousands = thousands % 1000
end
function toString()
return millions .. ',' .. thousands .. ',' .. hundreds
end
Roblox uses LuaU, which is derived from Lua. The thing is that Lua isn’t derived from anything. I think it might be that Roblox using a C# VM and may have taken some functionality from C# and integrated it into LuaU.
This is also why you can use += even though it isn’t fully documented.
No, that is not the case. The engineers behind Luau purposefully implemented some functions and operators specifically for Roblox. You can find a list of syntax differences here:
Specific functions should be documented on the wiki, but new ones take a bit to get added.
3.634325413636 e+17 would also be known as:
3.63432541363600000000000000000
e+17 is technically 17 more numbers, so they might not be 0’s. So I am guessing you wanna round this to like 3 or 3.6
Also, thats different. Thats putting the power of. For instance, 5 to the power of 3 is 125 (5x5x5)
Or 3 to the power of 2 is 3x3
But 3e+2 would be 300(3 with 2 zeros)
Thats not what I am saying. I am saying when the number said e+16 that means there is 16 more numbers, I was using 0’s as an example, but that number has 16 more numbers, it is just not showing it because it is so long.
What I am trying to say here is:
I was just saying that 3.634325413636 also has another 17 numbers (Not 16 I said that in the last thing sorry) and I was just using 17 zeros as an example.
You are getting a whole number but its in exponential value because you’re doing to the power of level.value with if its 17 like it is in your you would get 36,343,254,136,360,000 xp until the next level.