Number's precision became less

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Number's precision became less

Lizzy M
Hi, all:

I’ve got this problem:

I use a client(programmed by flex) to set the longitude and latitude:
longitude = -0.12345678901234567
latitude = 0.123456789012345678

Then, I captured the net packages to make sure that amf message
brought right values. As I expected, the values of longitude and
latitude were right:

<appendix>

But I printed debug messaged on the server, the longitude and latitude
turned as follow:

2010-07-20 10:57:16+0800 [-]  *** classobject.longitude:
-0.123456789012 classobject.latitude 0.123456789012

The precision has become less: from 18 to 12.

I used the pyamf lib to communicate with flex client.

Why it happens?

Thanks very much!!



--
Yours Sincerely,
Liz

_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users

amf_msg.jpg (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Number's precision became less

Nick Joyce
On 20 Jul 2010, at 13:27, Lizzy M wrote:

> Hi, all:
>
> I’ve got this problem:
>
> I use a client(programmed by flex) to set the longitude and latitude:
> longitude = -0.12345678901234567
> latitude = 0.123456789012345678
>
> Then, I captured the net packages to make sure that amf message
> brought right values. As I expected, the values of longitude and
> latitude were right:
>
> <appendix>
>
> But I printed debug messaged on the server, the longitude and latitude
> turned as follow:
>
> 2010-07-20 10:57:16+0800 [-]  *** classobject.longitude:
> -0.123456789012 classobject.latitude 0.123456789012
>
> The precision has become less: from 18 to 12.
>
> I used the pyamf lib to communicate with flex client.
>
> Why it happens?
>
> Thanks very much!!
>
>
>
> --
> Yours Sincerely,
> Liz
> <amf_msg.jpg>_______________________________________________
> PyAMF users mailing list - [hidden email]
> http://lists.pyamf.org/mailman/listinfo/users

Are you sure that the complete precision of the float is being logged?

For example, in python you can do the following (from the console):

>>> x = 0.123456789012345678
>>> '%.5f' % x
'0.12346'
>>> '%.12f' % x
'0.123456789012'
>>> '%.18f' % x
'0.123456789012345677'
>>> repr(x)
'0.12345678901234568'

_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Number's precision became less

Lizzy M
Yes, you are right, it seems that in python, real type number's
default precision is 12, so I need to tell python what precision I
want to use, then it can work well.

In my case, I tried using :
                if (None != classobject.longitude):
                    classobject.longitude = repr(classobject.longitude)
and then get this sql:
UPDATE b_taa_objects SET longitude=E'-0.12345678901234568',
latitude=E'0.12345678901234569' WHERE b_taa_objects.object_id =
-669452413.0

It seems better, though not the values I expected. But I think it's
something wrong when I use sqlalchemy. I will find that.

Thanks a lot!!

2010/7/20, Nick Joyce <[hidden email]>:

> On 20 Jul 2010, at 13:27, Lizzy M wrote:
>
>> Hi, all:
>>
>> I’ve got this problem:
>>
>> I use a client(programmed by flex) to set the longitude and latitude:
>> longitude = -0.12345678901234567
>> latitude = 0.123456789012345678
>>
>> Then, I captured the net packages to make sure that amf message
>> brought right values. As I expected, the values of longitude and
>> latitude were right:
>>
>> <appendix>
>>
>> But I printed debug messaged on the server, the longitude and latitude
>> turned as follow:
>>
>> 2010-07-20 10:57:16+0800 [-]  *** classobject.longitude:
>> -0.123456789012 classobject.latitude 0.123456789012
>>
>> The precision has become less: from 18 to 12.
>>
>> I used the pyamf lib to communicate with flex client.
>>
>> Why it happens?
>>
>> Thanks very much!!
>>
>>
>>
>> --
>> Yours Sincerely,
>> Liz
>> <amf_msg.jpg>_______________________________________________
>> PyAMF users mailing list - [hidden email]
>> http://lists.pyamf.org/mailman/listinfo/users
>
> Are you sure that the complete precision of the float is being logged?
>
> For example, in python you can do the following (from the console):
>
>>>> x = 0.123456789012345678
>>>> '%.5f' % x
> '0.12346'
>>>> '%.12f' % x
> '0.123456789012'
>>>> '%.18f' % x
> '0.123456789012345677'
>>>> repr(x)
> '0.12345678901234568'
>
> _______________________________________________
> PyAMF users mailing list - [hidden email]
> http://lists.pyamf.org/mailman/listinfo/users
>


--
Yours Sincerely,
Liz
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users