Z
zendraw
Guest
So recently i wanted to know how long a number can game maker have and people gave me various answers
@Bingdom https://forum.yoyogames.com/index.php?threads/biggest-number.43446/#post-267419
@TsukaYuriko -3.4E+38 to +3.4E+38 or -1.7E+308 to +1.7E+308, depending on whether a 32-bit or 64-bit float is used.
@hippyman Tsuka just told you the answer. Learn scientific notation.
@Joe Ellis Unsigned 64-bit integer: 18,446,744,073,709,551,615
signed 64-bit integer: 9,223,372,036,854,775,807
64-bit float: 4,503,599,627,370,495
Though cus all variable numbers are stored as floats, I guess 4,503,599,627,370,495 is the max value a variable can hold,
but buffers let you use u_64, so I think 18,446,744,073,709,551,615 is the max for that
@GMWolf Yeah but @Joe Ellis isn't 100% correct;
Numbers are not always stored as floats, the runtime will decide hat format is best and convert between them.
If you stick to integers, you should be able to get 32 or 64 bit numbers (depending on target platform, I believe).
Signed 32 bit numbers get you 2,147,483,647
Signed 64 bit gets you 9,223,372,036,854,775,807
-as @Joe Ellis stated, you can use buffers to store unsigned integers, however, when reading them, they will be converted again and you will lose that extra gain, so manipulation won't work.
-Finally, although your own variables will be cast to the most appropriate format (either a double precision float, or integers), remember that built in variables like X, y or image_angle are always stored as single precision floats. They go up to 3.402823 × 10^38.
However, you have to deal with precision.
For example, if you want 1mm precision, don't make you map larger than 16km, or you will have precision issues.
Joe Ellis @GMWolf Ahh, someone on here told me they're all stored as floats, is the sorting just a gms2 thing or has it always done that?
GMWolf As far as I know it's since GMS1.x, but could be before?
The thing is, what type is going to be used is undefined, so it's best to always assume its going to be a floating point number.
If you really, really need to do things with types, and sizes, then GM may not be the tool for the job. (Or write a dll or something)
zendraw what im trying to do is store values in a single value. like 1234567 where 12=val1 345=val2 67=val3. so i wanted to know how meny values i can store like this.
zendraw main reason is to save it as single value. when i use that value i fracture it in the manner i wrote in my previous comment.
Joe Ellis @zendraw if your doing it like that you may aswell use strings, then the length is unlimited or far more than 16-20 digits
like:
str = "1234567"
val1 = real(string_copy(str, 1, 2))
val2 = real(string_copy(str, 3, 3))
val3 = real(string_copy(str, 6, 2))
--------------------------------------------------------------------------------------------------------------------------------
and so i came to the conclusion i dont need to store them in a real value and limit myself, but a string and have an infinite number of values in one string as Joe suggested.
then i came with the problem how to store each value so that theres aways a pair of 4 numbers
like so 0321 0012 0004 0032
if i simply turn a real number into a string it will resault in 32112432 and if i try to extract those values again it will fail so what im doing to store the exact string back is this
basically you add 4 0`s to your values as a string and then remove what 0`s you dont need from that string and finally you combine them all.
now this works fine for me, if anyone has a better way to do it please do so, the reason for this topic is so people can learn somthing, and hopefully expand this idea, i think this is a great way to store great amount of info for items in a RPG without worrying about arrays and stuf. also making it in a thread was @TsukaYuriko `s idea so ban hur if its against the rules.
anyway any additions are welcomed. much love to @TsukaYuriko
@Bingdom https://forum.yoyogames.com/index.php?threads/biggest-number.43446/#post-267419
@TsukaYuriko -3.4E+38 to +3.4E+38 or -1.7E+308 to +1.7E+308, depending on whether a 32-bit or 64-bit float is used.
@hippyman Tsuka just told you the answer. Learn scientific notation.
@Joe Ellis Unsigned 64-bit integer: 18,446,744,073,709,551,615
signed 64-bit integer: 9,223,372,036,854,775,807
64-bit float: 4,503,599,627,370,495
Though cus all variable numbers are stored as floats, I guess 4,503,599,627,370,495 is the max value a variable can hold,
but buffers let you use u_64, so I think 18,446,744,073,709,551,615 is the max for that
@GMWolf Yeah but @Joe Ellis isn't 100% correct;
Numbers are not always stored as floats, the runtime will decide hat format is best and convert between them.
If you stick to integers, you should be able to get 32 or 64 bit numbers (depending on target platform, I believe).
Signed 32 bit numbers get you 2,147,483,647
Signed 64 bit gets you 9,223,372,036,854,775,807
-as @Joe Ellis stated, you can use buffers to store unsigned integers, however, when reading them, they will be converted again and you will lose that extra gain, so manipulation won't work.
-Finally, although your own variables will be cast to the most appropriate format (either a double precision float, or integers), remember that built in variables like X, y or image_angle are always stored as single precision floats. They go up to 3.402823 × 10^38.
However, you have to deal with precision.
For example, if you want 1mm precision, don't make you map larger than 16km, or you will have precision issues.
Joe Ellis @GMWolf Ahh, someone on here told me they're all stored as floats, is the sorting just a gms2 thing or has it always done that?
GMWolf As far as I know it's since GMS1.x, but could be before?
The thing is, what type is going to be used is undefined, so it's best to always assume its going to be a floating point number.
If you really, really need to do things with types, and sizes, then GM may not be the tool for the job. (Or write a dll or something)
zendraw what im trying to do is store values in a single value. like 1234567 where 12=val1 345=val2 67=val3. so i wanted to know how meny values i can store like this.
zendraw main reason is to save it as single value. when i use that value i fracture it in the manner i wrote in my previous comment.
Joe Ellis @zendraw if your doing it like that you may aswell use strings, then the length is unlimited or far more than 16-20 digits
like:
str = "1234567"
val1 = real(string_copy(str, 1, 2))
val2 = real(string_copy(str, 3, 3))
val3 = real(string_copy(str, 6, 2))
--------------------------------------------------------------------------------------------------------------------------------
and so i came to the conclusion i dont need to store them in a real value and limit myself, but a string and have an infinite number of values in one string as Joe suggested.
then i came with the problem how to store each value so that theres aways a pair of 4 numbers
like so 0321 0012 0004 0032
if i simply turn a real number into a string it will resault in 32112432 and if i try to extract those values again it will fail so what im doing to store the exact string back is this
Code:
t=string_insert(t, '0000', 5);
a=string_insert(a, '0000', 5);
ap=string_insert(ap, '0000', 5);
t=string_copy(t, string_length(t)-3, 4);
a=string_copy(a, string_length(a)-3, 4);
ap=string_copy(ap, string_length(ap)-3, 4);
return string(t)+string(a)+string(ap);
now this works fine for me, if anyone has a better way to do it please do so, the reason for this topic is so people can learn somthing, and hopefully expand this idea, i think this is a great way to store great amount of info for items in a RPG without worrying about arrays and stuf. also making it in a thread was @TsukaYuriko `s idea so ban hur if its against the rules.
anyway any additions are welcomed. much love to @TsukaYuriko