Help with handwritten advanced number system

no i’m sure OP is aware
unfortunately OP describe 3.4GB RAM usage fron a github page as low memory usage for some reason

Why would 3,4GB be big when I have 500GB in my laptop
image

Seems nice, will try it out.

My script works fine and I like how it looks it’s kinda cute.

Up to you

Will get there someday since I’m close to 100M

1 Like

I was waiting for 15 minutes :sob:

3.7GB was the max, I guess…
image

even if you wrote 1000 “if” statements per second, it would take you 5.69654579201940549258912e294 millenia to finish

rn is 2024, that is 2.024 millenia
take that number, double it, and multiply it by a number with 294 zeros
universe boutta end before you finish bro

1 Like

I have plenty of ram see:
image
It’s not that expensive.

2.024 doesn’t sound like much so I’ll go with it.

Just released 100 MILLION version

Download: Release 100 million update · sgisheree/Help-with-handwritten-advanced-number-system · GitHub
For some reason GitHub didn’t allowed me to upload this as normal LUA file so I had to put it as ZIP.

Enjoy this great andvanced number system!

Next goal: 1 billion.

can the next update support decimals

3 Likes

that is current year
universe is gone when you finish typing the double limit, it’s just that big
right now you’re heading for 9 zeros (1 billion)
the limit is 308 zeros (1.7 hundred thousand centillion)
you are not reaching that, even the computer won’t reach it in time

that is storage space, RAM is different

since you use windows, try following this to find out how much RAM you have:

  1. press ⊞ Win + S (bring up search bar
  2. type View RAM Info
  3. look for a thing called Installed RAM in the settings tab that pops up and then see what is next to it

A found it, it’s a lil smaller than I expected but still I think thats alright
image - 2024-05-31T133707.307

why you’re not believing in me? :frowning_face:

You really shouldn’t do that. Just do this…

function IsEven(num: number): boolean
      return num % 2 == 0
end

function IsOdd(num: number): boolean
      return not IsEven(num)
end

print(IsOdd(5))
print(IsEven(4))

You use the modulus operator. It just returns the remainder of division between x and y.
5 % 2 would be 1 because the remainder is 1.

2 % 2 would be 0 because there Is no remainder. But Not even numbers have a remainder.

the computer can generate code way faster than you do, you take a few seconds to type out a few lines, computer can probably do millions of lines in milliseconds (not 1 second, 0.001 seconds)
even if you can tell the computer to make the code for you, it can’t do it in time
you’re telling me you can?

mmm he calls it “too complicated”, very funny (yes guys, 4th grade math is too complicated!!)

I’ve noticed this topic for a while and I felt like I should put my word into here. If this is completely satire, then this shouldn’t be here at all. But if OP is actually trying, I would like to say this. OP, you seem to have a true passion for this. You have tried and were able to make a really long program and persist even though people were “trolling” you. Once again, if this is satire, then this shouldn’t be here. If you are serious, you should continue learning Luau and continue your work. You should really be taking the advice from others. The code that others are providing seems complicated as you call it. The simple code you have, however, causes a lag spike when using it and requires a LOT of hard work. I would simplify this a little for you. Let’s run through the “complicated” code step by step. It is 3 lines, but the one line in the middle is what we care about. Return means to send back something through a function. If you got a result from a function, and you called it through a variable, it would show that.

For example:
function hello()
return “yes”
end
print(hello())
It would return “yes”.

The next part is simple 4th grade mathematics. Basically, what it does is divide the inputted number down, and checks if it has any remainder. If the number has a remainder, it is odd. For example, if you divided 3 by 2, it would be 1.5, and .5 would be the remainder. If it has a remainder, it returns odd. If the number is 4, you do 4 divided by 2 and it returns 0 as the remainder, meaning it’s even.

If you are serious, I applaud your effort and hope you can learn better ways.

If you are joking around, you need to learn how to be serious on a serious platform, and should probably not make posts like this anymore.

1 Like

and, in this case, it’s worse for performance if you stack if statements, because the computer evaluates every elseif if the if is not true, and having that many operations would be big O(n). based off the number you put in, you want it to be big O(1), which using modulus does for you, and it’s way less operations for the computer to handle

I’m not a lawyer, but you should switch from the MIT licence to something like GPL so that companies can’t steal this code.

2 Likes

here is a version that does not require any math!

function getParity(No: number)
	if type(No) == "number" then
		local str = tostring(No)
		if str:find(".") then
			print("decimal")
		end
		local lastDigit = str:sub(str:len(), str:len())
		local odd = true
		if lastDigit == "2" then
			odd = false
		elseif lastDigit == "4" then
			odd = false
		elseif lastDigit == "6"  then
			odd = false
		elseif lastDigit == "8" then
			odd = false
		elseif lastDigit == "0" then
			odd = false
		end
		
		if odd then
			print("odd")
		else
			print("even")
		end
	else
		print("not a number")
	end
end

I mean, that is actually good…

suggestion: use ‘or’ instead of a chain of 'elseif’s when checking lastDigit

ok i’ll make it better, using a table saves space

local evenNumbers = {"2", "4", "6", "8", "0"}

function getParity(No: number)
	if type(No) == "number" then
		local str = tostring(No)
		if str:find(".") then
			print("decimal")
		end
		local lastDigit = str:sub(str:len(), str:len())
		local odd = true
		if table.find(evenNumbers, lastDigit) then
			odd = false
		end

		if odd then
			print("odd")
		else
			print("even")
		end
	else
		print("not a number")
	end
end
1 Like

that works
but i love doing pointlessly small optimizations so here’s what i’m gonna do

--!native
--!optimize 2
-- ^ added these 2 tags bc why not they speed things up a little bit
local even = {0, 2, 4, 6, 8}
local function binarySearch(array: {number}, target: number): number? -- binary search algorithm, like twice as fast as table.find, but best for sorted arrays of numbers, which we just so happen to have
	local min, max = 1, #array
	
	while min <= max do
		local mid = (max + min) // 2
		local value = array[mid]

		if value > target then
			max = mid - 1
		elseif value < target then
			min = mid + 1
		else
			return mid
		end
	end
	
	return nil
end

local function parity(x: number): "Even" | "Odd"
	assert(type(x) == "number", `invalid argument #1 to 'parity' (number expected, got {typeof(x)})`)
	local digitCount = string.len(tostring(x))
	local lastDigit = tonumber(string.sub(tostring(x), digitCount, digitCount))
	assert(lastDigit, "invalid number")

	return binarySearch(even, lastDigit) and "Even" or "Odd"
end

very unnecessary optimization bc the array is so smol but whatever

I just found a revolutionary thing called a “dictionary”

local map = {
	["0"] = "even",
	["1"] = "odd",
	["2"] = "even",
	["3"] = "odd",
	["4"] = "even",
	["5"] = "odd",
	["6"] = "even",
	["7"] = "odd",
	["8"] = "even",
	["9"] = "odd",
}

local function getParity(x: number)
	return map[string.sub(x, -1, -1)] or error("invalid number")
end