2

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
  • If you want to see them in hex, try this: struct.pack('d', -123.456).hex(" "): Out[37]: '77 be 9f 1a 2f dd 5e c0' Commented Jun 28, 2023 at 0:46

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Upvoted, it might surprise people, but ASCII chars are numbers too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.