Sorry in advance if I didn't choose the right tags for the question, I wasn't sure.
So I'm a programmer and writing a saving/loading system for data. The way I was serializing (saving) vectors is via creating lists and storing the vector coordinates in those lists. So if I have a Vector3, I save that vector as a list of 3 elements where list is x, list is y and list is z. When loading I just read the values from the list and create a vector from those values.
Then I thought, can't I just somehow convert the vector coords to a number, and just serialize/save that number? and when loading I go in reverse to get the vector?
If the vector's coords are single digits the solution is quite simple. Ex [1, 2, 3] => 123
It gets more tricky if the coords have more digits. I thought about a solution (which currently only works if the coords are integers, not floats) and this is what I came up with:
Given the vector [11, 7, 450] I also flatten the vector, so I get: 117450 and then append that number with 213. where 2 is the number of x's digits, 1 is y's digits and 3 is z's digits. So we get 117450213. Going in reverse is no problem.
My problem is how to deal with float numbers. I can deal with them the same way by storing the number of digits after each decimal place as well. So if we had [7.5, 12.75, 3.25] I'd convert that to 75 1275 325|11 22 12 (the spaces and | are just for clarity). The first 11 represents how many digits x has before and after the decimal point, so 1 before, 1 after. You get the idea. This however could yield large numbers quite easily so imagine a vector [100.32234, 24.24101, 200.5029333] ... yeah... not so great.
I'm sure there's a better way of doing it, so what's the best way to achieve what I want? And, is there an official mathematical term for what I'm trying to do?
Edit: Please note I don't want to store the values in an array, list or anything that allocates memory. That's why I want something to do with numbers and math (CPU effort more than memory)