[BangPypers] packing floating data

Srinivas Reddy Thatiparthy srinivas_thatiparthy at akebonosoft.com
Mon May 31 15:21:13 CEST 2010


Yes, you need to pack real and imaginary parts separately.I mean ,there is no way to pass Complex object to pack method(well,struct
performs conversions between Python values and C structs represented as
Python bytes objects),so

struct.pack('ff',realpart,imaginarypart) #provided both parts are floats.

Thanks&Regards,
Srinivas Reddy Thatiparthy, 
Mobile:9393099772, 



-----Original Message-----
From: bangpypers-bounces+srinivas_thatiparthy=akebonosoft.com at python.org on behalf of murugadoss
Sent: Mon 5/31/2010 6:22 PM
To: Bangalore Python Users Group - India
Subject: Re: [BangPypers] packing floating data
 
hi,

When i pack and unpack, i am able to get real part of the float number. can
anyone please tell me, how i can pack both the real and imaginary part. Do i
need to split n store the values ??

--
Thanks & Regards
V.Murugadoss


On Mon, May 31, 2010 at 9:14 PM, Noufal Ibrahim <noufal at gmail.com> wrote:

> On Mon, May 31, 2010 at 5:34 PM, murugadoss <murugadoss2884 at gmail.com>
> wrote:
> > Hi all,
> >
> > I am trying to pack a float value like 45.90,43.78,543.87. i am using
> > struct.pack( ) function. When i unpack (using struct.unpack) and print it
> i
> > am getting only real part of the number.
> >
> > Type of the variable is long,
> > var = 45.90
> > data = struct.pack("!l",float(var))
>
> http://docs.python.org/library/struct.html#format-characters
>
>
>
>
>
> --
> ~noufal
> http://nibrahim.net.in
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
_______________________________________________
BangPypers mailing list
BangPypers at python.org
http://mail.python.org/mailman/listinfo/bangpypers



More information about the BangPypers mailing list