Expand my Community achievements bar.

SOLVED

AMF Serialization and floats

Avatar

Level 2
I am transfering float values from Java DTOs to corresponding
AS objects using both FDS and remote objects. The Java float values
have a precision of 4 decimal places (verified before
serialization) yet when they are created in AS they have 16 decimal
places with values extending throughout the 16 digits. I suppose I
can round the values when I receive them at the client, but can
someone tell me if there's a better way to insure the destination
values are the same as the source?



Thanks,

Mike
1 Accepted Solution

Avatar

Correct answer by
Level 3
Hi Mike,



To serialize/deserialize data between Flash and Java
symmetric data types are necessary. ActionScript and ECMAScript
provide a Number datatype that equates to a Java double; it's an
8byte IEEE-754 double precision floating point value. They don't
provide a 4byte float datatype.



So your Java floats are being widened to Numbers on the
client. I'd recommend using double values on the server if possible
to avoid any potential mismatch.



Regards,

Seth

View solution in original post

1 Reply

Avatar

Correct answer by
Level 3
Hi Mike,



To serialize/deserialize data between Flash and Java
symmetric data types are necessary. ActionScript and ECMAScript
provide a Number datatype that equates to a Java double; it's an
8byte IEEE-754 double precision floating point value. They don't
provide a 4byte float datatype.



So your Java floats are being widened to Numbers on the
client. I'd recommend using double values on the server if possible
to avoid any potential mismatch.



Regards,

Seth