Game maker and "Long" numbers

simes007us

Member
Can game maker handle the number format of "long"?

I have an api call that's returning a number in a "long" format and it gets turned into a random number automatically. I checked that it's being returned correctly using charles proxy to see the net traffic.
 

simes007us

Member
Int64 is no use it seems. Once this the number has been rounded it looks like there is no way to un-round it. :(
 

Mercerenies

Member
You need to write a wrapper in the API you're using to convert it to a double in C (or whatever language you're using). GM supports double and char* and no other types.
 

dphsw

Member
Can game maker handle the number format of "long"?

I have an api call that's returning a number in a "long" format and it gets turned into a random number automatically. I checked that it's being returned correctly using charles proxy to see the net traffic.
If the 64 bits are being kept, but GameMaker is interpreting them as a double instead of a long (which would probably appear to a human as practically random) then you could use the buffer functions to convert it back. Create a 4-byte buffer, use buffer_write with a type of buffer_f64 to write the value in (based on the assumption that although it's a long, GML thinks it's a float64), and then buffer_read with some smaller types to read its bytes back out again. Or maybe it would work if you instantly read the value into a buffer without storing it in a variable (based on the assumption that it being stored in a variable is when GML converts it), like buffer_write(mybuffer,buffer_u64,api_function_call(argument));

Whatever you need such a large value for, hopefully you can just store it in a buffer until you need it again (i.e. if you need to send the value again to the same api, send it using buffer_read), or read out it's 32-bit parts, both of which should be able to be stored in variables, and figure out what you need to using those parts individually.
 
W

Wraithious

Guest
What I've done in the past is to write the number to a file as a string, and then read it back as real.
 

simes007us

Member
It's 11 digits. In the same API call I can return an INT of 10 digits just fine. The API responds with the "ID" number in the long format instead of an int.
 

Attachments

simes007us

Member
I'm currently using a show debug message to print the value and it always comes up with 148552885 or something.
 
Top