Them numbers are a bit to high they exceed the precision that Lua can accurately handle for integers. Lua uses 64-bit double-precision floating-point numbers, which limits the accuracy for large integers. It can accurately represent integers up to 2^53 (or 9,007,199,254,740,992) without losing precision.
Hi, I don’t understand English well, and I’m new to the Roblox programing. I don’t understand replies it’s hard for me. Me trying my best to create good script to make people happy , not to other. Please try to understand me.
this takes the last number of the number and checks if its even or not (the number is in a string because if it wasnt then the number was too big for roblox)
function isEven(number)
local stringNum = tostring(number)
local firstNumber = stringNum:sub(#stringNum,#stringNum)
return tonumber(firstNumber) % 2 == 0
end
print(isEven("111111111111111321454554353425433333333432578342786354287635478635428763452634528763458760"))
--returns true because the last nubmer "0" is even
Well if you know how the modulo (%) works you will understand.
The modulo (%) is associated with division.
Here’s an example:
Equation: 4 % 2
hmm idk lemme do division
4 / 2 = 2
alr the remainder of that is 0 cuz nothing is left over
ChatGPT trying to help you understand modulo so that its not complicated
Imagine you have 10 cookies and you want to share them equally with 3 friends. Each friend would get 3 cookies, and you’d have 1 cookie left over.
In math, this leftover cookie is like the “remainder” when you divide. We call this division with a remainder “modulo.”
So, if we say “10 modulo 3,” we’re asking, “What’s the remainder when we divide 10 by 3?”
In this case, the remainder is 1. So, 10 modulo 3 is 1. It’s like asking, “How many are left after sharing equally?”
Adding onto this post. This is the best method of finding even numbers:
local function CheckEvenOdd(x:string) -- The super cute number finder.
x = tostring(x)
if #x > 100 then
return "Number is too big for me. >w<" -- I am not a black hole. Give me something easily digestable!!
elseif #x < 2 then
return "Number is too small for me. >w<" -- You need to get better at providing bigger stuff.
end
x = string.reverse(x)
x = string.sub(x,1,1)
local the_last_Digit_of_x = tonumber(x) -- The last digit. The chosen one!!
local all_the_even_digits_till_ten = { -- My feelings for even numbers. x3
[0] = "Master Zero",
[2] = "Senpai Two",
[4] = "Oni-Chan Four",
[6] = "Daddy Six",
[8] = "Mommy Eight",
}
local all_the_odd_digits_till_ten = { -- My feelings for odd numbers. (ew)
[1] = "Uncle One",
[3] = "Annoying Three",
[5] = "Peasant Five",
[7] = "Overrated Seven",
[9] = "Ugly Nine",
}
local the_potential_odd_last_digit_of_x = all_the_odd_digits_till_ten[the_last_Digit_of_x] -- Is x an odd number? (ew)
local the_potential_even_last_digit_of_x = all_the_even_digits_till_ten[the_last_Digit_of_x] -- Is she an even? (:OOO)
if the_potential_even_last_digit_of_x then -- Is she even?
return "Oooo... the number is even!! OwO Because your number ends with "..the_potential_even_last_digit_of_x
elseif the_potential_odd_last_digit_of_x then -- Is she even a girl?
return "Awwwwww... the number is a filthy odd one... >_< Because your number ends with "..the_potential_odd_last_digit_of_x
else -- No... she must be trans then!! <3
return "Um... THE NUMBER IS TRANSGENDER! HOW DARE YOU ASSUME THEIR GENDER! HUH!? I AM GOING TO CANCEL YOU NOW! NOW NOW NOW!!!!"
end
end -- The end. :p
This script, while being the MOST accurate method of finding odds and even, also tells me why the number is odd or even.
this will help you support an infinite amount of numbers
--!native
local ServerStorage = game:GetService("ServerStorage")
local SUPPORT_COUNT = 100 -- Number Of Generated If Statments
local txt = "local ifEven \nlocal ifUnEven \nlocal number \nif number == 0 then \n\tifEven\n"
local scriptCopy = Instance.new("Script", ServerStorage)
for i=1, SUPPORT_COUNT do
txt = txt .. `elseif number == {i} then\n\t{i % 2 ==0 and "ifEven" or "ifUnEven"}\n`
end
txt = txt .. 'else\n\tprint("Unsopported number")\nend'
scriptCopy.Source = txt
add this script in server script service and run this command in the command line