| Reply | « Previous Thread | Next Thread » |
|
Hi,
Im implementing a communication protocol in pys60 and i need to convert from signed float (-122.7886577) to hex and from hex to signed float. How can i convert preserving the signal and the precision? At this time i can only make the conversion between int and hex. Tks for help. Marcos Davi Reis |
| davi.graner |
| View Public Profile |
| Find all posts by davi.graner |
|
Join Date: Nov 2007
Posts: 319
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
hi Marcos, fine ?
when I write network programs I like to use struct module. With it you have the necessary control like byte order, padding, and so on. Using struct.pack to format an output buffer is simple. Just check this link: http://docs.python.org/library/struct.html Code:
import struct
data = struct.pack("f",-123.456)
Marcelo Barros Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Conversion Hex to Decimal | heidis | General Symbian C++ | 9 | 2008-10-18 12:55 |
| Conversion from signed 2 unsigned | Shaddy_ | General Symbian C++ | 1 | 2007-03-12 11:55 |
| conversion of float to text | shafali gupta | Symbian User Interface | 1 | 2005-01-25 20:17 |
| Float using henson float | Pandaemonium | Mobile Java General | 2 | 2004-03-24 11:40 |
| UDH Hex conversion | yewseong | Smart Messaging | 1 | 2003-08-28 19:04 |