-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Long Integer lossy (native function parameter) casting conversion #14059
Comments
yes, I'm setting |
It seems to be Date.now() being cast to Double instead of Long then (Inside Java I suppose). But is working correctly when returned by Date.now() as toString() is doing right. |
correct. But it's all long numbers. With to String it will be a string so it doesn't need to convert it. But I don't know at which point the conversion is |
No, the Debugger is doing wrong!! :-/ |
I don't think it is doing a |
I knew that JS try to fit all the datatypes in one putting pointers and other into the NaN space, but the long should not fit into a double NaN space. So I do not know what's happening... |
I have searched and made sure there are no existing issues for the issue I am filing
Description
The long integer conversion is not consistent between Android and iOS. Especially I found it in the Ti.Network.HTTPClient send method and in the alert function.
In Android the send method performs a data type conversion error on the POST request parameters, while on iOS the conversion is done correctly.
Also with the alert function the same problem is present.
The long integer seems to be casted to a double instead of remaining a long integer.
The long integer data type is wrongly converted to scientific notation format, corrupting for example timestamps generated by Date.now().
It appears that if the toString conversion is done at JavaScript level is correct, while if done at Java level is wrong!
FIXING WORKAROUND: Convert the long integer to String before passing it to the send method!
Expected Behavior
Consistent behaviour between iOS and Android.
Non lossy data transfer and integrity of long integer data types.
Actual behavior
Android wrongly converts long integer to float scentific notation.
Reproducible sample
alert(Date.now());
HttpClientInstance.send( { timestamp: Date.now() } );
FIXING WORKAROUND: HttpClientInstance.send( { timestamp: Date.now().toString() } );
Steps to reproduce
Just invoke: alert(Date.now());
But this works: alert(({ts:Date.now()}).ts+'');
because the conversion is done outside the function call.
Crate an instance of HTTPClient, and make a request with a long integer in the parameters of the first argument of the send method, for example using Date.now().
Platform
Android
SDK version you are using
12.3.0.GA
Alloy version you are using
No response
The text was updated successfully, but these errors were encountered: