views:

163

answers:

1

I want to convert -123.456 into a C double for network transmission in python. So I tried this:

struct.pack('d', -123.456)

I get this as a result:

'w\xbe\x9f\x1a/\xdd^\xc0'

Obviously there is some hex in there, but what is with the w, /, and ^ sprinkled in there?

+1  A: 

They are, respectively, a "w", "/", and "^". Some byte sequences do correspond to ASCII characters.

Ignacio Vazquez-Abrams
Upvoted, it might surprise people, but ASCII chars are numbers too.
Daniel Goldberg
So simple, of course!
Jake